summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNg Zhi An <zhin@google.com>2023-02-13 02:16:44 -0800
committerGitHub <noreply@github.com>2023-02-13 10:16:44 +0000
commit4bf38aaefa33bcf89a8e707b406c49090c5a00e3 (patch)
tree48cdd95426bc2fe4c40ed1842425a9b0c5fc8528 /src
parent330d3a0e914504420902fa4b58af4645a06a969e (diff)
downloadwabt-4bf38aaefa33bcf89a8e707b406c49090c5a00e3.tar.gz
wabt-4bf38aaefa33bcf89a8e707b406c49090c5a00e3.tar.bz2
wabt-4bf38aaefa33bcf89a8e707b406c49090c5a00e3.zip
objdump: take care of opcodes whose bytes are non-canonical leb128 (#1632)
Fixes #1631
Diffstat (limited to 'src')
-rw-r--r--src/binary-reader-objdump.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/binary-reader-objdump.cc b/src/binary-reader-objdump.cc
index eac21ef3..23f2016f 100644
--- a/src/binary-reader-objdump.cc
+++ b/src/binary-reader-objdump.cc
@@ -587,7 +587,10 @@ Result BinaryReaderObjdumpDisassemble::OnOpcode(Opcode opcode) {
}
if (last_opcode_end) {
- if (state->offset != last_opcode_end + opcode.GetLength()) {
+ // Takes care of cases where opcode's bytes was a non-canonical leb128
+ // encoding. In this case, opcode.GetLength() under-reports the length,
+ // since it canonicalizes the opcode.
+ if (state->offset < last_opcode_end + opcode.GetLength()) {
Opcode missing_opcode = Opcode::FromCode(data_[last_opcode_end]);
const char* opcode_name = missing_opcode.GetName();
fprintf(stderr,