summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/DataExtractor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Support/DataExtractor.cpp')
-rw-r--r--llvm/lib/Support/DataExtractor.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/llvm/lib/Support/DataExtractor.cpp b/llvm/lib/Support/DataExtractor.cpp
index 6328d779b3d..18e1423b546 100644
--- a/llvm/lib/Support/DataExtractor.cpp
+++ b/llvm/lib/Support/DataExtractor.cpp
@@ -157,12 +157,12 @@ uint64_t DataExtractor::getULEB128(uint32_t *offset_ptr) const {
byte = Data[offset++];
result |= uint64_t(byte & 0x7f) << shift;
shift += 7;
- if ((byte & 0x80) == 0)
- break;
+ if ((byte & 0x80) == 0) {
+ *offset_ptr = offset;
+ return result;
+ }
}
-
- *offset_ptr = offset;
- return result;
+ return 0;
}
int64_t DataExtractor::getSLEB128(uint32_t *offset_ptr) const {
@@ -178,14 +178,14 @@ int64_t DataExtractor::getSLEB128(uint32_t *offset_ptr) const {
byte = Data[offset++];
result |= uint64_t(byte & 0x7f) << shift;
shift += 7;
- if ((byte & 0x80) == 0)
- break;
+ if ((byte & 0x80) == 0) {
+ // Sign bit of byte is 2nd high order bit (0x40)
+ if (shift < 64 && (byte & 0x40))
+ result |= -(1ULL << shift);
+
+ *offset_ptr = offset;
+ return result;
+ }
}
-
- // Sign bit of byte is 2nd high order bit (0x40)
- if (shift < 64 && (byte & 0x40))
- result |= -(1ULL << shift);
-
- *offset_ptr = offset;
- return result;
+ return 0;
}
OpenPOWER on IntegriCloud