From e792c35822f5bcb1a6376e8131417e9e67e6782c Mon Sep 17 00:00:00 2001 From: Marcin Kolny Date: Wed, 14 Feb 2024 09:18:37 +0000 Subject: [PATCH] Fix null pointer access in fast-interp when configurable soft bound check is enabled (#3150) The wasm_interp_call_func_bytecode is called for the first time with the empty module/exec_env to generate a global_handle_table. Before that happens though, the function checks if the module instance has bounds check enabled. Because the module instance is null, the program crashes. This PR added an extra check to prevent the crashes. --- core/iwasm/common/wasm_memory.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/iwasm/common/wasm_memory.c b/core/iwasm/common/wasm_memory.c index 019e0c129..ce7c30ace 100644 --- a/core/iwasm/common/wasm_memory.c +++ b/core/iwasm/common/wasm_memory.c @@ -104,6 +104,10 @@ static inline bool is_bounds_checks_enabled(WASMModuleInstanceCommon *module_inst) { #if WASM_CONFIGURABLE_BOUNDS_CHECKS != 0 + if (!module_inst) { + return true; + } + return wasm_runtime_is_bounds_checks_enabled(module_inst); #else return true;