Skip to content

Commit

Permalink
fix problem in wasm_module_malloc (#374)
Browse files Browse the repository at this point in the history
  • Loading branch information
xujuntwt95329 authored Sep 7, 2020
1 parent 2e0cef3 commit 2135bad
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/iwasm/interpreter/wasm_runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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);
}

Expand Down

0 comments on commit 2135bad

Please sign in to comment.