[PATCH] [Support] fix the ULEB128 decoding bug.
Alex Lorenz
arphaman at gmail.com
Fri Aug 22 09:39:01 PDT 2014
Closed by commit rL216268 (authored by @arphaman).
REPOSITORY
rL LLVM
http://reviews.llvm.org/D5029
Files:
llvm/trunk/include/llvm/Support/LEB128.h
llvm/trunk/unittests/Support/LEB128Test.cpp
Index: llvm/trunk/unittests/Support/LEB128Test.cpp
===================================================================
--- llvm/trunk/unittests/Support/LEB128Test.cpp
+++ llvm/trunk/unittests/Support/LEB128Test.cpp
@@ -106,6 +106,7 @@
EXPECT_DECODE_ULEB128_EQ(0xffu, "\xff\x01");
EXPECT_DECODE_ULEB128_EQ(0x100u, "\x80\x02");
EXPECT_DECODE_ULEB128_EQ(0x101u, "\x81\x02");
+ EXPECT_DECODE_ULEB128_EQ(4294975616ULL, "\x80\xc1\x80\x80\x10");
// Decode ULEB128 with extra padding bytes
EXPECT_DECODE_ULEB128_EQ(0u, "\x80\x00");
Index: llvm/trunk/include/llvm/Support/LEB128.h
===================================================================
--- llvm/trunk/include/llvm/Support/LEB128.h
+++ llvm/trunk/include/llvm/Support/LEB128.h
@@ -82,7 +82,7 @@
uint64_t Value = 0;
unsigned Shift = 0;
do {
- Value += (*p & 0x7f) << Shift;
+ Value += uint64_t(*p & 0x7f) << Shift;
Shift += 7;
} while (*p++ >= 128);
if (n)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D5029.12846.patch
Type: text/x-patch
Size: 953 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140822/c76d5c04/attachment.bin>
More information about the llvm-commits
mailing list