aboutsummaryrefslogtreecommitdiff
path: root/lib/darwin
diff options
context:
space:
mode:
Diffstat (limited to 'lib/darwin')
-rw-r--r--lib/darwin/read.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/darwin/read.c b/lib/darwin/read.c
index 2e5b746..a0a5d8e 100644
--- a/lib/darwin/read.c
+++ b/lib/darwin/read.c
@@ -9,11 +9,11 @@ bool read_leb128(void **ptr, void *end, bool is_signed, uint64_t *out) {
return false;
bit = *p++;
uint64_t k = bit & 0x7f;
- if (shift < sizeof(uint64_t) * 8)
+ if (shift < 64)
result |= k << shift;
shift += 7;
} while (bit & 0x80);
- if (is_signed && (bit & 0x40))
+ if (is_signed && (bit & 0x40) && shift < 64)
result |= ~((uint64_t) 0) << shift;
*ptr = p;
if (out)