Skip to content

Commit 59f761b

Browse files
authored
aot compiler: Track non-0x00 tableindex as ref types use (#3695)
Any use of a table index that isn't exactly a null byte (`0x00`) means that the module makes use of the reference types proposal. This is important to track because `aot_compiler.c` will blindly assume that all table indices are a single byte long otherwise. This fixes a crash in WAMR for modules that contain multi-byte encodings of table indices in `call_indirect` but make no other use of reference types features.
1 parent a44c487 commit 59f761b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

core/iwasm/interpreter/wasm_loader.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12004,6 +12004,14 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
1200412004

1200512005
read_leb_uint32(p, p_end, type_idx);
1200612006
#if WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0
12007+
#if WASM_ENABLE_WAMR_COMPILER != 0
12008+
if (*p != 0x00) {
12009+
// Any non-0x00 byte requires the ref types proposal.
12010+
// This is different from checking the table_idx value
12011+
// since `0x80 0x00` etc. are all valid encodings of zero.
12012+
module->is_ref_types_used = true;
12013+
}
12014+
#endif
1200712015
read_leb_uint32(p, p_end, table_idx);
1200812016
#else
1200912017
CHECK_BUF(p, p_end, 1);

0 commit comments

Comments
 (0)