gdi32: Check header pointer in CreateDIBitmap

Nikolay Sivov bunglehead at gmail.com
Sun May 3 12:21:45 CDT 2009


http://bugs.winehq.org/show_bug.cgi?id=18331

Reported to help.

Changelog:
    - Check header pointer in CreateDIBitmap with some tests

>From 1e6b5139108afadac102caf65d566a0a5039fead Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <bunglehead at gmail.com>
Date: Sun, 3 May 2009 12:42:00 +0400
Subject: Check header pointer in CreateDIBitmap

---
 dlls/gdi32/dib.c          |    2 ++
 dlls/gdi32/tests/bitmap.c |    9 ++++++++-
 2 files changed, 10 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..6a5f10a 100644
--- a/dlls/gdi32/tests/bitmap.c
+++ b/dlls/gdi32/tests/bitmap.c
@@ -144,7 +144,14 @@ 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.
     */
-- 
1.5.6.5





More information about the wine-patches mailing list