- Add more check of parametres in GetDIBits
authorDmitry Chapyshev <dmitry@reactos.org>
Thu, 5 Mar 2009 12:22:35 +0000 (12:22 +0000)
committerDmitry Chapyshev <dmitry@reactos.org>
Thu, 5 Mar 2009 12:22:35 +0000 (12:22 +0000)
svn path=/trunk/; revision=39882

reactos/dll/win32/gdi32/objects/bitmap.c

index 9650f14..cf322a0 100644 (file)
@@ -418,7 +418,13 @@ GetDIBits(
            }
         }
      }
-     pvSafeBits = RtlAllocateHeap(GetProcessHeap(), 0, cjBmpScanSize);
+
+     if ((ULONG)lpvBits & (sizeof(DWORD) - 1))
+     {
+         pvSafeBits = RtlAllocateHeap(RtlGetProcessHeap(), 0, cjBmpScanSize);
+         if (!pvSafeBits)
+            return Ret;
+     }
   }
 
   Ret = NtGdiGetDIBitsInternal(hDC,
@@ -430,9 +436,12 @@ GetDIBits(
                                uUsage,
                                cjBmpScanSize,
                                0);
-  if ( lpvBits != pvSafeBits)
+  if (lpvBits != pvSafeBits)
   {
-     RtlCopyMemory( lpvBits, pvSafeBits, cjBmpScanSize);
+     if (Ret)
+     {
+        RtlCopyMemory(lpvBits, pvSafeBits, cjBmpScanSize);
+     }
      RtlFreeHeap(RtlGetProcessHeap(), 0, pvSafeBits);
   }
   return Ret;