In wasm32, fix potential conversion overflow when enlarging 65536 pages (#4064)

fix enlarge 65536 pages conversion overflow in wasm32
This commit is contained in:
TianlongLiang
2025-02-06 14:48:53 +08:00
committed by GitHub
parent c99ae24fb6
commit e6a47d5cee

View File

@ -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;