Fix module_realloc with NULL ptr issue (#1175)

Fix module_realloc with NULL ptr issue reported by #1173.
This commit is contained in:
Wenyong Huang 2022-05-19 11:57:33 +08:00 committed by GitHub
parent d7a2888b18
commit c72501781a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

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

View File

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