Skip to content

Commit c52434c

Browse files
committed
Fix null pointer access in fast interpreter mode when configurable software bound check is enabled
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. I added an extra check to prevent the crashes.
1 parent 7cac053 commit c52434c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

core/iwasm/interpreter/wasm_interp_fast.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -1483,8 +1483,9 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
14831483
#if !defined(OS_ENABLE_HW_BOUND_CHECK) \
14841484
|| WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS == 0
14851485
#if WASM_CONFIGURABLE_BOUNDS_CHECKS != 0
1486-
bool disable_bounds_checks = !wasm_runtime_is_bounds_checks_enabled(
1487-
(WASMModuleInstanceCommon *)module);
1486+
bool disable_bounds_checks = !module
1487+
&& !wasm_runtime_is_bounds_checks_enabled(
1488+
(WASMModuleInstanceCommon *)module);
14881489
#else
14891490
bool disable_bounds_checks = false;
14901491
#endif

0 commit comments

Comments
 (0)