From ce44e0ec0cda6329879b73ab272a518d2e60ab23 Mon Sep 17 00:00:00 2001 From: Marcin Kolny Date: Tue, 12 Mar 2024 09:46:11 +0000 Subject: [PATCH] Allow converting the zero wasm address to native (#3215) This allows to know the beginning of the wasm address space. At the moment to achieve that, we need to apply a `hack wasm_runtime_addr_app_to_native(X)-X` to get the beginning of WASM memory in the nativ code, but I don't see a good reason why not to allow zero address as a parameter value for this function. --- core/iwasm/common/wasm_memory.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/core/iwasm/common/wasm_memory.c b/core/iwasm/common/wasm_memory.c index b2fba441..61ab7492 100644 --- a/core/iwasm/common/wasm_memory.c +++ b/core/iwasm/common/wasm_memory.c @@ -426,15 +426,13 @@ wasm_runtime_addr_app_to_native(WASMModuleInstanceCommon *module_inst_comm, SHARED_MEMORY_UNLOCK(memory_inst); return addr; } - } - /* If bounds checks is disabled, return the address directly */ - else if (app_offset != 0) { SHARED_MEMORY_UNLOCK(memory_inst); - return addr; + return NULL; } + /* If bounds checks is disabled, return the address directly */ SHARED_MEMORY_UNLOCK(memory_inst); - return NULL; + return addr; } uint64