Commit 1441311d authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

gdi32: Avoid null pointer dereference in CreateDIBSection.

parent 02bf65a7
......@@ -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");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment