From e6a47d5ceea40cbcb7bffb1dcd89cdb776d8ceae Mon Sep 17 00:00:00 2001 From: TianlongLiang <111852609+TianlongLiang@users.noreply.github.com> Date: Thu, 6 Feb 2025 14:48:53 +0800 Subject: [PATCH] In wasm32, fix potential conversion overflow when enlarging 65536 pages (#4064) fix enlarge 65536 pages conversion overflow in wasm32 --- core/iwasm/common/wasm_memory.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/iwasm/common/wasm_memory.c b/core/iwasm/common/wasm_memory.c index 4f3d8689f..d4ec6158f 100644 --- a/core/iwasm/common/wasm_memory.c +++ b/core/iwasm/common/wasm_memory.c @@ -1389,7 +1389,7 @@ wasm_enlarge_memory_internal(WASMModuleInstanceCommon *module, if (full_size_mmaped) { #ifdef BH_PLATFORM_WINDOWS if (!os_mem_commit(memory->memory_data_end, - (mem_offset_t)(total_size_new - total_size_old), + total_size_new - total_size_old, MMAP_PROT_READ | MMAP_PROT_WRITE)) { ret = false; goto return_func; @@ -1397,12 +1397,12 @@ wasm_enlarge_memory_internal(WASMModuleInstanceCommon *module, #endif if (os_mprotect(memory->memory_data_end, - (mem_offset_t)(total_size_new - total_size_old), + total_size_new - total_size_old, MMAP_PROT_READ | MMAP_PROT_WRITE) != 0) { #ifdef BH_PLATFORM_WINDOWS os_mem_decommit(memory->memory_data_end, - (mem_offset_t)(total_size_new - total_size_old)); + total_size_new - total_size_old); #endif ret = false; goto return_func;