From 66d2196e7c97a67813c8bfeb70de6cd32e5c5673 Mon Sep 17 00:00:00 2001 From: Sjoerd van der Berg Date: Mon, 14 Jul 2003 11:06:37 +0000 Subject: [PATCH] Incorrect calculation of size for alloc and realloc Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1130 --- src/ints/xms.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ints/xms.cpp b/src/ints/xms.cpp index 1e9e0a7d..70693fb6 100644 --- a/src/ints/xms.cpp +++ b/src/ints/xms.cpp @@ -121,7 +121,7 @@ Bitu XMS_AllocateMemory(Bitu size, Bit16u& handle) while (!xms_handles[index].free) { if (++index>XMS_HANDLES) return XMS_OUT_OF_HANDLES; } - Bitu pages=(size/4) + (size & 3) ? 1 : 0; + Bitu pages=(size/4) + ((size & 3) ? 1 : 0); MemHandle mem=MEM_AllocatePages(pages,true); if (!mem) return XMS_OUT_OF_SPACE; xms_handles[index].free=false; @@ -224,7 +224,7 @@ Bitu XMS_ResizeMemory(Bitu handle, Bitu newSize) if (InvalidHandle(handle)) return XMS_INVALID_HANDLE; // Block has to be unlocked if (xms_handles[handle].locked>0) return XMS_BLOCK_LOCKED; - Bitu pages=newSize/4 + (newSize & 3) ? 1 : 0; + Bitu pages=newSize/4 + ((newSize & 3) ? 1 : 0); if (MEM_ReAllocatePages(xms_handles[handle].mem,pages,true)) { return 0; } else return XMS_OUT_OF_SPACE;