gdi32: Avoid null pointer dereference in CreateDIBSection.
This commit is contained in:
parent
02bf65a752
commit
1441311d36
|
@ -1258,6 +1258,11 @@ HBITMAP WINAPI CreateDIBSection(HDC hdc, CONST BITMAPINFO *bmi, UINT usage,
|
|||
DWORD compression, sizeImage;
|
||||
void *mapBits = NULL;
|
||||
|
||||
if(!bmi){
|
||||
if(bits) *bits = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (((bitmap_type = DIB_GetBitmapInfo( &bmi->bmiHeader, &width, &height,
|
||||
&planes, &bpp, &compression, &sizeImage )) == -1))
|
||||
return 0;
|
||||
|
|
|
@ -416,6 +416,13 @@ static void test_dibsections(void)
|
|||
pbmi->bmiHeader.biCompression = BI_RGB;
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
|
||||
/* invalid pointer for BITMAPINFO
|
||||
(*bits should be NULL on error) */
|
||||
bits = (BYTE*)0xdeadbeef;
|
||||
hdib = CreateDIBSection(hdc, NULL, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
|
||||
ok(hdib == NULL && bits == NULL, "CreateDIBSection failed for invalid parameter: bmi == 0x0\n");
|
||||
|
||||
hdib = CreateDIBSection(hdc, pbmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
|
||||
ok(hdib != NULL, "CreateDIBSection error %d\n", GetLastError());
|
||||
ok(GetObject(hdib, sizeof(DIBSECTION), &dibsec) != 0, "GetObject failed for DIBSection\n");
|
||||
|
|
Loading…
Reference in New Issue