Skip to content

Commit b0736e2

Browse files
authored
Fix issues reported by Coverity (#2083)
Get exec_env_tls at the beginning of execute_post_instantiate_functions to avoid it is uninitialized when is_sub_inst is false.
1 parent 19ab3b8 commit b0736e2

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

core/iwasm/aot/aot_runtime.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ execute_post_instantiate_functions(AOTModuleInstance *module_inst,
930930
AOTFunctionInstance *call_ctors_func = NULL;
931931
WASMModuleInstanceCommon *module_inst_main = NULL;
932932
#ifdef OS_ENABLE_HW_BOUND_CHECK
933-
WASMExecEnv *exec_env_tls = NULL;
933+
WASMExecEnv *exec_env_tls = wasm_runtime_get_exec_env_tls();
934934
#endif
935935
WASMExecEnv *exec_env = NULL, *exec_env_created = NULL;
936936
bool ret = false;
@@ -976,7 +976,6 @@ execute_post_instantiate_functions(AOTModuleInstance *module_inst,
976976
if (is_sub_inst) {
977977
bh_assert(exec_env_main);
978978
#ifdef OS_ENABLE_HW_BOUND_CHECK
979-
exec_env_tls = wasm_runtime_get_exec_env_tls();
980979
bh_assert(exec_env_tls == exec_env_main);
981980
(void)exec_env_tls;
982981
#endif

core/iwasm/interpreter/wasm_runtime.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ execute_post_instantiate_functions(WASMModuleInstance *module_inst,
10141014
#endif
10151015
WASMModuleInstanceCommon *module_inst_main = NULL;
10161016
#ifdef OS_ENABLE_HW_BOUND_CHECK
1017-
WASMExecEnv *exec_env_tls = NULL;
1017+
WASMExecEnv *exec_env_tls = wasm_runtime_get_exec_env_tls();
10181018
#endif
10191019
WASMExecEnv *exec_env = NULL, *exec_env_created = NULL;
10201020
bool ret = false;
@@ -1060,7 +1060,6 @@ execute_post_instantiate_functions(WASMModuleInstance *module_inst,
10601060
if (is_sub_inst) {
10611061
bh_assert(exec_env_main);
10621062
#ifdef OS_ENABLE_HW_BOUND_CHECK
1063-
exec_env_tls = wasm_runtime_get_exec_env_tls();
10641063
bh_assert(exec_env_tls == exec_env_main);
10651064
(void)exec_env_tls;
10661065
#endif

0 commit comments

Comments
 (0)