- Handle failed memory allocation in CreateDIBitmap, check initialize option before allocating and copying

svn path=/trunk/; revision=42856
This commit is contained in:
Gregor Schneider
2009-08-22 16:56:28 +00:00
parent aa5af3351e
commit 5420cabe1a
+10 -3
View File
@@ -501,11 +501,18 @@ CreateDIBitmap( HDC hDC,
hBmp = GetStockObject(DEFAULT_BITMAP);
else
{
if ( Bits )
if ( Bits && Init == CBM_INIT )
{
pvSafeBits = RtlAllocateHeap(GetProcessHeap(), 0, cjBmpScanSize);
if ( pvSafeBits )
if (pvSafeBits == NULL)
{
hBmp = NULL;
goto Exit;
}
else
{
RtlCopyMemory( pvSafeBits, Bits, cjBmpScanSize);
}
}
hBmp = NtGdiCreateDIBitmapInternal(hDC,
@@ -520,7 +527,7 @@ CreateDIBitmap( HDC hDC,
0,
0);
if ( Bits )
if ( Bits && Init == CBM_INIT )
RtlFreeHeap(RtlGetProcessHeap(), 0, pvSafeBits);
}
Exit: