Don't lock unnecessarily and don't leak a bitmap object in case of failure

svn path=/trunk/; revision=30034
This commit is contained in:
Ged Murphy 2007-11-01 10:06:11 +00:00
parent 7110b8e047
commit a03d9e441c

View file

@ -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;
}