diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-08-20 10:52:11 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-08-20 10:52:11 +0000 |
commit | 46aed739555d2f821691b323d46de7ad7a75d5e7 (patch) | |
tree | 0577d6fc0b1c7248e0b691f22a7a86f6cb54c690 /lib | |
parent | bee05dc8408d363335bb623a4f3349ff90639d35 (diff) | |
download | external_llvm-46aed739555d2f821691b323d46de7ad7a75d5e7.zip external_llvm-46aed739555d2f821691b323d46de7ad7a75d5e7.tar.gz external_llvm-46aed739555d2f821691b323d46de7ad7a75d5e7.tar.bz2 |
DataExtractor: Fix integer truncation issues in LEB128 extraction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162201 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Support/DataExtractor.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/Support/DataExtractor.cpp b/lib/Support/DataExtractor.cpp index dc21155..3d5cce0 100644 --- a/lib/Support/DataExtractor.cpp +++ b/lib/Support/DataExtractor.cpp @@ -139,7 +139,7 @@ uint64_t DataExtractor::getULEB128(uint32_t *offset_ptr) const { while (isValidOffset(offset)) { byte = Data[offset++]; - result |= (byte & 0x7f) << shift; + result |= uint64_t(byte & 0x7f) << shift; shift += 7; if ((byte & 0x80) == 0) break; @@ -160,7 +160,7 @@ int64_t DataExtractor::getSLEB128(uint32_t *offset_ptr) const { while (isValidOffset(offset)) { byte = Data[offset++]; - result |= (byte & 0x7f) << shift; + result |= uint64_t(byte & 0x7f) << shift; shift += 7; if ((byte & 0x80) == 0) break; @@ -168,7 +168,7 @@ int64_t DataExtractor::getSLEB128(uint32_t *offset_ptr) const { // Sign bit of byte is 2nd high order bit (0x40) if (shift < 64 && (byte & 0x40)) - result |= -(1 << shift); + result |= -(1ULL << shift); *offset_ptr = offset; return result; |