In wasm32, fix potential conversion overflow when enlarging 65536 pages (#4064)
fix enlarge 65536 pages conversion overflow in wasm32
This commit is contained in:
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user