From 0cc91508606c1219ca90ffd68e0765fa40a93539 Mon Sep 17 00:00:00 2001 From: Wojciech Kosior Date: Mon, 21 Sep 2020 13:41:30 +0200 Subject: fix leb decoding --- tools/parse_module.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/parse_module.c b/tools/parse_module.c index 85540af..c9a5b12 100644 --- a/tools/parse_module.c +++ b/tools/parse_module.c @@ -34,7 +34,7 @@ int leb_u32(FILE *handle, uint32_t *result) return -1; } - if (encoded[i] >= 0) + if (encoded[i] < 128) break; if (i == 4) { @@ -46,7 +46,7 @@ int leb_u32(FILE *handle, uint32_t *result) decoded = 0; for (j = i; j >= 0; j--) - decoded = (decoded << 7) | (encoded[i] & 0x7F); + decoded = (decoded << 7) | (encoded[j] & 0x7F); if (decoded > UINT32_MAX) { PRERR(MSG_BAD_NUM_ENC); -- cgit v1.2.3