Skip to content

Commit 1c5034b

Browse files
authored
Fix a bug of the return value of memory_instantiate (#1616)
Since `memory` is not NULL, memory_instantiate will return non-null value when failed.
1 parent 86d3f30 commit 1c5034b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

core/iwasm/interpreter/wasm_runtime.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ memory_instantiate(WASMModuleInstance *module_inst, WASMMemoryInstance *memory,
296296
#endif
297297
bh_assert(memory_data_size <= 4 * (uint64)BH_GB);
298298

299+
bh_assert(memory != NULL);
299300
#ifndef OS_ENABLE_HW_BOUND_CHECK
300301
if (memory_data_size > 0
301302
&& !(memory->memory_data =
@@ -416,7 +417,7 @@ memory_instantiate(WASMModuleInstance *module_inst, WASMMemoryInstance *memory,
416417
os_munmap(mapped_mem, map_size);
417418
#endif
418419
fail1:
419-
return memory;
420+
return NULL;
420421
}
421422

422423
/**

0 commit comments

Comments
 (0)