mirror of
https://github.com/reactos/reactos.git
synced 2024-09-06 02:37:06 +00:00
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:
parent
7110b8e047
commit
a03d9e441c
|
@ -39,7 +39,6 @@ IntGdiCreateBitmap(
|
||||||
UINT BitsPixel,
|
UINT BitsPixel,
|
||||||
IN OPTIONAL LPBYTE pBits)
|
IN OPTIONAL LPBYTE pBits)
|
||||||
{
|
{
|
||||||
PBITMAPOBJ bmp;
|
|
||||||
HBITMAP hBitmap;
|
HBITMAP hBitmap;
|
||||||
SIZEL Size;
|
SIZEL Size;
|
||||||
LONG WidthBytes;
|
LONG WidthBytes;
|
||||||
|
@ -71,24 +70,25 @@ IntGdiCreateBitmap(
|
||||||
return 0;
|
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)
|
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;
|
return hBitmap;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue