Module: wine Branch: master Commit: 0f9bc1d3b7d3529a8162eb8ef5537d314d691121 URL: http://source.winehq.org/git/wine.git/?a=commit;h=0f9bc1d3b7d3529a8162eb8ef5...
Author: Nikolay Sivov bunglehead@gmail.com Date: Sun May 3 12:42:00 2009 +0400
gdi32: Check header pointer in CreateDIBitmap.
---
dlls/gdi32/dib.c | 2 ++ dlls/gdi32/tests/bitmap.c | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/dlls/gdi32/dib.c b/dlls/gdi32/dib.c index 0dceaa8..086eaae 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 bfbeee0..a0d4531 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. */