diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index bab053fc1..606ffa05c 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -1837,7 +1837,7 @@ aot_module_realloc(AOTModuleInstance *module_inst, uint32 ptr, uint32 size, if (memory_inst->heap_handle.ptr) { addr = mem_allocator_realloc( memory_inst->heap_handle.ptr, - (uint8 *)memory_inst->memory_data.ptr + ptr, size); + ptr ? (uint8 *)memory_inst->memory_data.ptr + ptr : NULL, size); } /* Only support realloc in WAMR's app heap */ diff --git a/core/iwasm/interpreter/wasm_runtime.c b/core/iwasm/interpreter/wasm_runtime.c index 870a5695b..c6b77f0a7 100644 --- a/core/iwasm/interpreter/wasm_runtime.c +++ b/core/iwasm/interpreter/wasm_runtime.c @@ -1917,8 +1917,8 @@ wasm_module_realloc(WASMModuleInstance *module_inst, uint32 ptr, uint32 size, } if (memory->heap_handle) { - addr = mem_allocator_realloc(memory->heap_handle, - memory->memory_data + ptr, size); + addr = mem_allocator_realloc( + memory->heap_handle, ptr ? memory->memory_data + ptr : NULL, size); } /* Only support realloc in WAMR's app heap */