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/obj... ============================================================================== --- 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; }