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.
This commit is contained in:
liang.he 2022-10-19 07:23:03 +08:00 committed by GitHub
parent 86d3f30600
commit 1c5034bdfa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
}
/**