From a03d9e441c4c220e034b546ee4cf44cc191084a8 Mon Sep 17 00:00:00 2001 From: Ged Murphy Date: Thu, 1 Nov 2007 10:06:11 +0000 Subject: [PATCH] Don't lock unnecessarily and don't leak a bitmap object in case of failure svn path=/trunk/; revision=30034 --- .../subsystems/win32/win32k/objects/bitmaps.c | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/reactos/subsystems/win32/win32k/objects/bitmaps.c b/reactos/subsystems/win32/win32k/objects/bitmaps.c index 6af80bf504a..c36b56f1e3d 100644 --- a/reactos/subsystems/win32/win32k/objects/bitmaps.c +++ b/reactos/subsystems/win32/win32k/objects/bitmaps.c @@ -39,7 +39,6 @@ IntGdiCreateBitmap( UINT BitsPixel, IN OPTIONAL LPBYTE pBits) { - PBITMAPOBJ bmp; HBITMAP hBitmap; SIZEL Size; LONG WidthBytes; @@ -71,24 +70,25 @@ IntGdiCreateBitmap( 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; }