[NTVDM]
authorAleksandar Andrejevic <aandrejevic@reactos.org>
Sat, 17 May 2014 15:29:07 +0000 (15:29 +0000)
committerAleksandar Andrejevic <aandrejevic@reactos.org>
Sat, 17 May 2014 15:29:07 +0000 (15:29 +0000)
DosResizeMemory shouldn't succeed unless the memory block has been resized to the specified amount.

svn path=/trunk/; revision=63331

reactos/subsystems/ntvdm/dos/dos32krnl/dos.c

index b0769cd..6925c26 100644 (file)
@@ -249,6 +249,14 @@ static BOOLEAN DosResizeMemory(WORD BlockData, WORD NewSize, WORD *MaxAvailable)
         /* Set the maximum possible size of the block */
         ReturnSize += NextMcb->Size + 1;
 
+        if (ReturnSize < NewSize)
+        {
+            DPRINT("Cannot expand memory block: insufficient free segments available!\n");
+            DosLastError = ERROR_NOT_ENOUGH_MEMORY;
+            Success = FALSE;
+            goto Done;
+        }
+
         /* Maximize the current block */
         Mcb->Size = ReturnSize;
         Mcb->BlockType = NextMcb->BlockType;