From 1c5034bdfa952ef3ad1ac925651dccfa8e0f160c Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Wed, 19 Oct 2022 07:23:03 +0800 Subject: [PATCH] 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. --- core/iwasm/interpreter/wasm_runtime.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/iwasm/interpreter/wasm_runtime.c b/core/iwasm/interpreter/wasm_runtime.c index 7d00b5ea6..2731c0aad 100644 --- a/core/iwasm/interpreter/wasm_runtime.c +++ b/core/iwasm/interpreter/wasm_runtime.c @@ -296,6 +296,7 @@ memory_instantiate(WASMModuleInstance *module_inst, WASMMemoryInstance *memory, #endif bh_assert(memory_data_size <= 4 * (uint64)BH_GB); + bh_assert(memory != NULL); #ifndef OS_ENABLE_HW_BOUND_CHECK if (memory_data_size > 0 && !(memory->memory_data = @@ -416,7 +417,7 @@ fail2: os_munmap(mapped_mem, map_size); #endif fail1: - return memory; + return NULL; } /**