From 64baf54d8881e9475a9e579a82c0f6148022f350 Mon Sep 17 00:00:00 2001 From: funera1 <60760935+funera1@users.noreply.github.com> Date: Tue, 3 Oct 2023 11:33:00 +0900 Subject: [PATCH] Fix label index out-of-range references in op_br_table_cache (#2615) Fixed a bug in the processing of the br_table_cache opcode that caused out-of-range references when the label index was greater than the length of the label. --- core/iwasm/interpreter/wasm_interp_classic.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/iwasm/interpreter/wasm_interp_classic.c b/core/iwasm/interpreter/wasm_interp_classic.c index ce090d1f..50860d3a 100644 --- a/core/iwasm/interpreter/wasm_interp_classic.c +++ b/core/iwasm/interpreter/wasm_interp_classic.c @@ -1418,6 +1418,8 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, while (node_cache) { node_next = bh_list_elem_next(node_cache); if (node_cache->br_table_op_addr == frame_ip - 1) { + if (lidx > node_cache->br_count) + lidx = node_cache->br_count; depth = node_cache->br_depths[lidx]; goto label_pop_csp_n; }