fix a mem leak in win32k bitmap code

svn path=/trunk/; revision=32247
This commit is contained in:
Timo Kreuzer 2008-02-10 02:33:11 +00:00
parent 7099cce31f
commit 412242bf24
2 changed files with 16 additions and 21 deletions

View file

@ -70,23 +70,22 @@ IntGdiCreateBitmap(
return 0; return 0;
} }
PBITMAPOBJ bmp = BITMAPOBJ_LockBitmap( hBitmap );
if (bmp == NULL)
{
NtGdiDeleteObject(hBitmap);
return NULL;
}
bmp->flFlags = BITMAPOBJ_IS_APIBITMAP;
if (NULL != pBits) if (NULL != pBits)
{ {
PBITMAPOBJ bmp = BITMAPOBJ_LockBitmap( hBitmap );
if (bmp == NULL)
{
NtGdiDeleteObject(hBitmap);
return NULL;
}
bmp->flFlags = BITMAPOBJ_IS_APIBITMAP;
IntSetBitmapBits(bmp, bmp->SurfObj.cjBits, pBits); IntSetBitmapBits(bmp, bmp->SurfObj.cjBits, pBits);
BITMAPOBJ_UnlockBitmap( bmp );
} }
BITMAPOBJ_UnlockBitmap( bmp );
DPRINT("IntGdiCreateBitmap : %dx%d, %d BPP colors, topdown %d, returning %08x\n", DPRINT("IntGdiCreateBitmap : %dx%d, %d BPP colors, topdown %d, returning %08x\n",
Size.cx, Size.cy, BitsPixel, (Height < 0 ? 1 : 0), hBitmap); Size.cx, Size.cy, BitsPixel, (Height < 0 ? 1 : 0), hBitmap);

View file

@ -809,12 +809,9 @@ IntCreateDIBitmap(PDC Dc, const BITMAPINFOHEADER *header,
LONG compr; LONG compr;
LONG dibsize; LONG dibsize;
BOOL fColor; BOOL fColor;
SIZEL size;
if (DIB_GetBitmapInfo( header, &width, &height, &planes, &bpp, &compr, &dibsize ) == -1) return 0; if (DIB_GetBitmapInfo( header, &width, &height, &planes, &bpp, &compr, &dibsize ) == -1) return 0;
// Check if we should create a monochrome or color bitmap. We create a monochrome bitmap only if it has exactly 2 // Check if we should create a monochrome or color bitmap. We create a monochrome bitmap only if it has exactly 2
// colors, which are black followed by white, nothing else. In all other cases, we create a color bitmap. // colors, which are black followed by white, nothing else. In all other cases, we create a color bitmap.
@ -866,12 +863,11 @@ IntCreateDIBitmap(PDC Dc, const BITMAPINFOHEADER *header,
} }
else else
{ {
size.cx = width; handle = IntGdiCreateBitmap(width,
size.cy = abs(height); height,
1,
handle = IntCreateBitmap(size, DIB_GetDIBWidthBytes(width, 1), BMF_1BPP, 1,
(height < 0 ? BMF_TOPDOWN : 0) | BMF_NOZEROINIT, NULL);
NULL);
} }
if (height < 0) if (height < 0)