aboutsummaryrefslogtreecommitdiff
path: root/lib/darwin/read.c
diff options
context:
space:
mode:
authorYifan Lu2016-11-23 14:34:33 -0600
committerYifan Lu2016-11-23 14:34:33 -0600
commitbd5ebb7a0a4e102731de72832f3e12e9f54d541a (patch)
treebef4f637a270d3f7d2551ac74a89e6b4bad8adec /lib/darwin/read.c
parentFixed proper encoding of PUSH (STMDB) as ARM manual was wrong... (diff)
parentavoid UB (diff)
downloadsubstitute-bd5ebb7a0a4e102731de72832f3e12e9f54d541a.tar.gz
Merge branch 'master' of https://github.com/comex/substitute
Diffstat (limited to 'lib/darwin/read.c')
-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)