[PATCH] D77304: [llvm/Support] Don't crash on empty nullptr ranges when decoding LEBs
Pavel Labath via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 2 07:01:24 PDT 2020
labath updated this revision to Diff 254510.
labath added a comment.
Upload the diff properly
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D77304/new/
https://reviews.llvm.org/D77304
Files:
llvm/include/llvm/Support/LEB128.h
llvm/unittests/Support/LEB128Test.cpp
Index: llvm/unittests/Support/LEB128Test.cpp
===================================================================
--- llvm/unittests/Support/LEB128Test.cpp
+++ llvm/unittests/Support/LEB128Test.cpp
@@ -113,6 +113,9 @@
EXPECT_EQ(EXPECTED, Actual); \
} while (0)
+ // Don't crash
+ EXPECT_EQ(0u, decodeULEB128(nullptr, nullptr, nullptr));
+
// Decode ULEB128
EXPECT_DECODE_ULEB128_EQ(0u, "\x00");
EXPECT_DECODE_ULEB128_EQ(1u, "\x01");
@@ -148,6 +151,9 @@
EXPECT_EQ(EXPECTED, Actual); \
} while (0)
+ // Don't crash
+ EXPECT_EQ(0, decodeSLEB128(nullptr, nullptr, nullptr));
+
// Decode SLEB128
EXPECT_DECODE_SLEB128_EQ(0L, "\x00");
EXPECT_DECODE_SLEB128_EQ(1L, "\x01");
Index: llvm/include/llvm/Support/LEB128.h
===================================================================
--- llvm/include/llvm/Support/LEB128.h
+++ llvm/include/llvm/Support/LEB128.h
@@ -134,7 +134,7 @@
if (error)
*error = nullptr;
do {
- if (end && p == end) {
+ if (p == end) {
if (error)
*error = "malformed uleb128, extends past end";
if (n)
@@ -168,7 +168,7 @@
if (error)
*error = nullptr;
do {
- if (end && p == end) {
+ if (p == end) {
if (error)
*error = "malformed sleb128, extends past end";
if (n)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77304.254510.patch
Type: text/x-patch
Size: 1302 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200402/551ff232/attachment.bin>
More information about the llvm-commits
mailing list