From 9c9dbe1726d95dc92cfceb10e38210fb3ee4aec7 Mon Sep 17 00:00:00 2001 From: "liang.he@intel.com" Date: Tue, 18 Oct 2022 09:43:01 +0000 Subject: [PATCH] Fix a bug of the return value of memory_instantiate 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 7d00b5ea65..2731c0aad1 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 @@ memory_instantiate(WASMModuleInstance *module_inst, WASMMemoryInstance *memory, os_munmap(mapped_mem, map_size); #endif fail1: - return memory; + return NULL; } /**