Fix some issues reported by Coverity (#1150)

module_wasm_app.c: add return value check for wasm_runtime_call_wasm
aot_runtime.c: add return value check for aot_get_default_memory
aot_runtime.c: add return value check before calling wasm app malloc/free func
wasm_runtime_common.c: fix dead code warning in wasm_runtime_load_from_sections
aot_emit_memory.c: fix potential integer overflow issue
wasm_runtime.c: remove dead code in memory_instantiate, add assertion for globals
samples simple/gui/littlevgl: fix fields of struct sigaction initialization issue
host-tool: add return value check for sendto
This commit is contained in:
Wenyong Huang
2022-05-07 16:51:43 +08:00
committed by GitHub
parent d62543c99c
commit 2bac6a42a7
10 changed files with 41 additions and 33 deletions

View File

@ -222,6 +222,8 @@ memory_instantiate(WASMModuleInstance *module_inst, uint32 num_bytes_per_page,
/* Adjust __heap_base global value */
global_idx = module->aux_heap_base_global_index;
bh_assert(module_inst->globals
&& global_idx < module_inst->global_count);
global_addr = module_inst->global_data
+ module_inst->globals[global_idx].data_offset;
*(uint32 *)global_addr = aux_heap_base;
@ -403,19 +405,6 @@ memories_instantiate(const WASMModule *module, WASMModuleInstance *module_inst,
}
}
if (mem_index == 0) {
/**
* no import memory and define memory, but still need heap
* for wasm code
*/
if (!(memory = memories[mem_index++] =
memory_instantiate(module_inst, 0, 0, 0, heap_size, 0,
error_buf, error_buf_size))) {
memories_deinstantiate(module_inst, memories, memory_count);
return NULL;
}
}
bh_assert(mem_index == memory_count);
(void)module_inst;
return memories;