[llvm] r301510 - [Support] Fix overflow in SLEB128 decoding.

Ahmed Bougacha via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 26 19:09:45 PDT 2017


Author: ab
Date: Wed Apr 26 21:09:44 2017
New Revision: 301510

URL: http://llvm.org/viewvc/llvm-project?rev=301510&view=rev
Log:
[Support] Fix overflow in SLEB128 decoding.

decodeULEB128 was fixed in r216268, but decodeSLEB128 always had the
same issue, which is now exposed in r301369.

Modified:
    llvm/trunk/include/llvm/Support/LEB128.h

Modified: llvm/trunk/include/llvm/Support/LEB128.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/LEB128.h?rev=301510&r1=301509&r2=301510&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/LEB128.h (original)
+++ llvm/trunk/include/llvm/Support/LEB128.h Wed Apr 26 21:09:44 2017
@@ -160,7 +160,7 @@ inline int64_t decodeSLEB128(const uint8
       return 0;
     }
     Byte = *p++;
-    Value |= ((Byte & 0x7f) << Shift);
+    Value |= (int64_t(Byte & 0x7f) << Shift);
     Shift += 7;
   } while (Byte >= 128);
   // Sign extend negative numbers.




More information about the llvm-commits mailing list