diff options
author | Wojciech Kosior <kwojtus@protonmail.com> | 2020-09-21 13:41:30 +0200 |
---|---|---|
committer | Wojciech Kosior <kwojtus@protonmail.com> | 2020-09-21 13:41:30 +0200 |
commit | 0cc91508606c1219ca90ffd68e0765fa40a93539 (patch) | |
tree | 2e2bc4c142a3280c0eb60e6582c2bf36cb8e675c | |
parent | ca4e5c1cca9f0e6db5f564e6786a356bcdffb956 (diff) | |
download | AGH-engineering-thesis-0cc91508606c1219ca90ffd68e0765fa40a93539.tar.gz AGH-engineering-thesis-0cc91508606c1219ca90ffd68e0765fa40a93539.zip |
fix leb decoding
-rw-r--r-- | tools/parse_module.c | 4 |
1 files 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); |