From 0f9bc1d3b7d3529a8162eb8ef5537d314d691121 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov <bunglehead@gmail.com> Date: Sun, 3 May 2009 12:42:00 +0400 Subject: [PATCH] gdi32: Check header pointer in CreateDIBitmap. --- dlls/gdi32/dib.c | 2 ++ dlls/gdi32/tests/bitmap.c | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/dlls/gdi32/dib.c b/dlls/gdi32/dib.c index 0dceaa80949..086eaaea0ad 100644 --- a/dlls/gdi32/dib.c +++ b/dlls/gdi32/dib.c @@ -1097,6 +1097,8 @@ HBITMAP WINAPI CreateDIBitmap( HDC hdc, const BITMAPINFOHEADER *header, DWORD compr, size; DC *dc; + if (!header) return 0; + if (DIB_GetBitmapInfo( header, &width, &height, &planes, &bpp, &compr, &size ) == -1) return 0; if (width < 0) diff --git a/dlls/gdi32/tests/bitmap.c b/dlls/gdi32/tests/bitmap.c index bfbeee05670..a0d4531d511 100644 --- a/dlls/gdi32/tests/bitmap.c +++ b/dlls/gdi32/tests/bitmap.c @@ -144,7 +144,12 @@ static void test_createdibitmap(void) bmih.biPlanes = 1; bmih.biBitCount = 32; bmih.biCompression = BI_RGB; - + + hbm = CreateDIBitmap(hdc, NULL, CBM_INIT, NULL, NULL, 0); + ok(hbm == NULL, "CreateDIBitmap should fail\n"); + hbm = CreateDIBitmap(hdc, NULL, 0, NULL, NULL, 0); + ok(hbm == NULL, "CreateDIBitmap should fail\n"); + /* First create an un-initialised bitmap. The depth of the bitmap should match that of the hdc and not that supplied in bmih. */ -- GitLab