[NTVDM]
authorAleksandar Andrejevic <aandrejevic@reactos.org>
Sat, 18 Apr 2015 04:21:28 +0000 (04:21 +0000)
committerAleksandar Andrejevic <aandrejevic@reactos.org>
Sat, 18 Apr 2015 04:21:28 +0000 (04:21 +0000)
Fix the range check in VgaReadMemory and VgaWriteMemory.

svn path=/trunk/; revision=67238

reactos/subsystems/mvdm/ntvdm/hardware/video/vga.c

index d4b39e9..079499c 100644 (file)
@@ -1910,7 +1910,7 @@ VOID NTAPI VgaReadMemory(ULONG Address, PVOID Buffer, ULONG Size)
     PUCHAR BufPtr = (PUCHAR)Buffer;
 
     DPRINT("VgaReadMemory: Address 0x%08X, Size %lu\n", Address, Size);
-    Address = max(min(Address, VgaGetVideoLimitAddress() - 1), VgaGetVideoBaseAddress());
+    Address = min(max(Address, VgaGetVideoLimitAddress() - 1), VgaGetVideoBaseAddress());
     Size = min(Size, VgaGetVideoLimitAddress() - Address + 1);
 
     /* Ignore if video RAM access is disabled */
@@ -1939,7 +1939,7 @@ BOOLEAN NTAPI VgaWriteMemory(ULONG Address, PVOID Buffer, ULONG Size)
     PUCHAR BufPtr = (PUCHAR)Buffer;
 
     DPRINT("VgaWriteMemory: Address 0x%08X, Size %lu\n", Address, Size);
-    Address = max(min(Address, VgaGetVideoLimitAddress() - 1), VgaGetVideoBaseAddress());
+    Address = min(max(Address, VgaGetVideoLimitAddress() - 1), VgaGetVideoBaseAddress());
     Size = min(Size, VgaGetVideoLimitAddress() - Address + 1);
 
     /* Ignore if video RAM access is disabled */