fix problem in wasm_module_malloc (#374)

This commit is contained in:
Xu Jun 2020-09-07 17:32:00 +08:00 committed by GitHub
parent 2e0cef3ef1
commit 2135badc54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1580,6 +1580,9 @@ wasm_module_malloc(WASMModuleInstance *module_inst, uint32 size,
size, &offset)) {
return 0;
}
/* If we use app's malloc function,
the default memory may be changed while memory growing */
memory = module_inst->default_memory;
addr = offset ? memory->memory_data + offset : NULL;
}
@ -1589,6 +1592,7 @@ wasm_module_malloc(WASMModuleInstance *module_inst, uint32 size,
}
if (p_native_addr)
*p_native_addr = addr;
return (uint32)(addr - memory->memory_data);
}