Skip to content

Commit 2135bad

Browse files
fix problem in wasm_module_malloc (#374)
1 parent 2e0cef3 commit 2135bad

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

core/iwasm/interpreter/wasm_runtime.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,6 +1580,9 @@ wasm_module_malloc(WASMModuleInstance *module_inst, uint32 size,
15801580
size, &offset)) {
15811581
return 0;
15821582
}
1583+
/* If we use app's malloc function,
1584+
the default memory may be changed while memory growing */
1585+
memory = module_inst->default_memory;
15831586
addr = offset ? memory->memory_data + offset : NULL;
15841587
}
15851588

@@ -1589,6 +1592,7 @@ wasm_module_malloc(WASMModuleInstance *module_inst, uint32 size,
15891592
}
15901593
if (p_native_addr)
15911594
*p_native_addr = addr;
1595+
15921596
return (uint32)(addr - memory->memory_data);
15931597
}
15941598

0 commit comments

Comments
 (0)