- Handle failed memory allocation in CreateDIBitmap, check initialize option before...
authorGregor Schneider <grschneider@gmail.com>
Sat, 22 Aug 2009 16:56:28 +0000 (16:56 +0000)
committerGregor Schneider <grschneider@gmail.com>
Sat, 22 Aug 2009 16:56:28 +0000 (16:56 +0000)
svn path=/trunk/; revision=42856

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

index 44b1662..f94c31a 100644 (file)
@@ -501,11 +501,18 @@ CreateDIBitmap( HDC hDC,
      hBmp = GetStockObject(DEFAULT_BITMAP);
   else
   {
-     if ( Bits )
+     if ( Bits && Init == CBM_INIT )
      {
         pvSafeBits = RtlAllocateHeap(GetProcessHeap(), 0, cjBmpScanSize);
-        if ( pvSafeBits )
+        if (pvSafeBits == NULL)
+        {
+            hBmp = NULL;
+            goto Exit;
+        }
+        else
+        {
            RtlCopyMemory( pvSafeBits, Bits, cjBmpScanSize);
+        }
      }
 
      hBmp = NtGdiCreateDIBitmapInternal(hDC,
@@ -520,7 +527,7 @@ CreateDIBitmap( HDC hDC,
                                         0,
                                         0);
 
-     if ( Bits )
+     if ( Bits && Init == CBM_INIT )
         RtlFreeHeap(RtlGetProcessHeap(), 0, pvSafeBits);
   }
 Exit: