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:
@ -654,6 +654,10 @@ memories_instantiate(AOTModuleInstance *module_inst, AOTModule *module,
|
||||
|
||||
/* Get default memory instance */
|
||||
memory_inst = aot_get_default_memory(module_inst);
|
||||
if (!memory_inst) {
|
||||
/* Ignore setting memory init data if no memory inst is created */
|
||||
return true;
|
||||
}
|
||||
|
||||
for (i = 0; i < module->mem_init_data_count; i++) {
|
||||
data_seg = module->mem_init_data_list[i];
|
||||
@ -1794,9 +1798,9 @@ aot_module_malloc(AOTModuleInstance *module_inst, uint32 size,
|
||||
malloc_func =
|
||||
aot_lookup_function(module_inst, malloc_func_name, malloc_func_sig);
|
||||
|
||||
bh_assert(malloc_func);
|
||||
if (!execute_malloc_function(module_inst, malloc_func, retain_func,
|
||||
size, &offset)) {
|
||||
if (!malloc_func
|
||||
|| !execute_malloc_function(module_inst, malloc_func, retain_func,
|
||||
size, &offset)) {
|
||||
return 0;
|
||||
}
|
||||
addr = offset ? (uint8 *)memory_inst->memory_data.ptr + offset : NULL;
|
||||
@ -1889,8 +1893,8 @@ aot_module_free(AOTModuleInstance *module_inst, uint32 ptr)
|
||||
if (!free_func && module->retain_func_index != (uint32)-1)
|
||||
free_func = aot_lookup_function(module_inst, "__unpin", "(i)i");
|
||||
|
||||
bh_assert(free_func);
|
||||
execute_free_function(module_inst, free_func, ptr);
|
||||
if (free_func)
|
||||
execute_free_function(module_inst, free_func, ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user