From 76392b546b66cc8ab6563d99b634747490e69a94 Mon Sep 17 00:00:00 2001 From: Alix ANNERAUD Date: Sun, 2 Mar 2025 22:14:30 +0100 Subject: [PATCH] fix: handle null exec_env in instruction metering checks --- core/iwasm/interpreter/wasm_interp_classic.c | 5 ++++- core/iwasm/interpreter/wasm_interp_fast.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/core/iwasm/interpreter/wasm_interp_classic.c b/core/iwasm/interpreter/wasm_interp_classic.c index 092afe347..96601c585 100644 --- a/core/iwasm/interpreter/wasm_interp_classic.c +++ b/core/iwasm/interpreter/wasm_interp_classic.c @@ -1623,7 +1623,10 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, uint32 cache_index, type_index, param_cell_num, cell_num; #if WASM_INSTRUCTION_METERING != 0 - int instructions_left = exec_env->instructions_to_execute; + int instructions_left = -1; + if (exec_env) { + instructions_left = exec_env->instructions_to_execute; + } #endif #if WASM_ENABLE_EXCE_HANDLING != 0 diff --git a/core/iwasm/interpreter/wasm_interp_fast.c b/core/iwasm/interpreter/wasm_interp_fast.c index 7b9f181d1..5a793d04b 100644 --- a/core/iwasm/interpreter/wasm_interp_fast.c +++ b/core/iwasm/interpreter/wasm_interp_fast.c @@ -1524,7 +1524,10 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module, uint8 opcode = 0, local_type, *global_addr; #if WASM_INSTRUCTION_METERING != 0 - int instructions_left = exec_env->instructions_to_execute; + int instructions_left = -1; + if (exec_env) { + instructions_left = exec_env->instructions_to_execute; + } #endif #if !defined(OS_ENABLE_HW_BOUND_CHECK) \ || WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS == 0