Skip to content

Commit 29811a1

Browse files
committed
Allow all LEB128 encodings of zero for table index
Even without reference types, the table index can be encoded in multiple ways (e.g. `0x80 0x00`). This fixes the handling of these (valid) files by always reading the table index as a LEB128.
1 parent 1362a30 commit 29811a1

File tree

2 files changed

+0
-10
lines changed

2 files changed

+0
-10
lines changed

core/iwasm/interpreter/wasm_loader.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12082,12 +12082,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
1208212082
WASMFuncType *func_type;
1208312083

1208412084
read_leb_uint32(p, p_end, type_idx);
12085-
#if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
1208612085
read_leb_uint32(p, p_end, table_idx);
12087-
#else
12088-
CHECK_BUF(p, p_end, 1);
12089-
table_idx = read_uint8(p);
12090-
#endif
1209112086
if (!check_table_index(module, table_idx, error_buf,
1209212087
error_buf_size)) {
1209312088
goto fail;

core/iwasm/interpreter/wasm_mini_loader.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6592,12 +6592,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
65926592

65936593
read_leb_uint32(p, p_end, type_idx);
65946594

6595-
#if WASM_ENABLE_REF_TYPES != 0
65966595
read_leb_uint32(p, p_end, table_idx);
6597-
#else
6598-
CHECK_BUF(p, p_end, 1);
6599-
table_idx = read_uint8(p);
6600-
#endif
66016596
if (!check_table_index(module, table_idx, error_buf,
66026597
error_buf_size)) {
66036598
goto fail;

0 commit comments

Comments
 (0)