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) 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");