[ros-diffs] [gedmurphy] 30034: Don't lock unnecessarily and don't leak a bitmap object in case of failure

gedmurphy at svn.reactos.org gedmurphy at svn.reactos.org
Thu Nov 1 11:06:12 CET 2007


Author: gedmurphy
Date: Thu Nov  1 13:06:11 2007
New Revision: 30034

URL: http://svn.reactos.org/svn/reactos?rev=30034&view=rev
Log:
Don't lock unnecessarily and don't leak a bitmap object in case of failure

Modified:
    trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c

Modified: trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c?rev=30034&r1=30033&r2=30034&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c Thu Nov  1 13:06:11 2007
@@ -39,7 +39,6 @@
     UINT  BitsPixel,
     IN OPTIONAL LPBYTE pBits)
 {
-   PBITMAPOBJ bmp;
    HBITMAP hBitmap;
    SIZEL Size;
    LONG WidthBytes;
@@ -71,24 +70,25 @@
       return 0;
    }
 
-   DPRINT("IntGdiCreateBitmap:%dx%d, %d BPP colors returning %08x\n",
-          Size.cx, Size.cy, BitsPixel, hBitmap);
-
-   bmp = BITMAPOBJ_LockBitmap( hBitmap );
-   if (bmp == NULL)
-   {
-      /* FIXME should we free the hBitmap or return it ?? */
-      return 0;
-   }
-
-   bmp->flFlags = BITMAPOBJ_IS_APIBITMAP;
-
    if (NULL != pBits)
    {
-      IntSetBitmapBits(bmp, bmp->SurfObj.cjBits, pBits);
+       PBITMAPOBJ bmp = BITMAPOBJ_LockBitmap( hBitmap );
+       if (bmp == NULL)
+       {
+          NtGdiDeleteObject(hBitmap);
+          return NULL;
+       }
+
+       bmp->flFlags = BITMAPOBJ_IS_APIBITMAP;
+
+       IntSetBitmapBits(bmp, bmp->SurfObj.cjBits, pBits);
+
+
+       BITMAPOBJ_UnlockBitmap( bmp );
    }
 
-   BITMAPOBJ_UnlockBitmap( bmp );
+   DPRINT("IntGdiCreateBitmap : %dx%d, %d BPP colors, topdown %d, returning %08x\n",
+          Size.cx, Size.cy, BitsPixel, (Height < 0 ? 1 : 0), hBitmap);
 
    return hBitmap;
 }




More information about the Ros-diffs mailing list