From b3aaf2abc0964bbc3555c6fd272b5638885a5b0f Mon Sep 17 00:00:00 2001 From: Wenyong Huang Date: Tue, 16 Jan 2024 21:55:10 +0800 Subject: [PATCH] Check passive mode in fast-jit table.init (#3031) Reported in https://github.com/bytecodealliance/wasm-micro-runtime/issues/3021. --- core/iwasm/fast-jit/fe/jit_emit_table.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/iwasm/fast-jit/fe/jit_emit_table.c b/core/iwasm/fast-jit/fe/jit_emit_table.c index b8ed6a1d..a2f5ce51 100644 --- a/core/iwasm/fast-jit/fe/jit_emit_table.c +++ b/core/iwasm/fast-jit/fe/jit_emit_table.c @@ -112,6 +112,9 @@ wasm_init_table(WASMModuleInstance *inst, uint32 tbl_idx, uint32 elem_idx, if (bh_bitmap_get_bit(inst->e->common.elem_dropped, elem_idx)) goto out_of_bounds; + if (!wasm_elem_is_passive(inst->module->table_segments[elem_idx].mode)) + goto out_of_bounds; + bh_memcpy_s((uint8 *)tbl + offsetof(WASMTableInstance, elems) + dst_offset * sizeof(uint32), (uint32)((tbl_sz - dst_offset) * sizeof(uint32)),