[PATCH] user32: check for valid pointer in CURSORICON_CreateIconFromBMI

Wolfram Sang wolfram at the-dreams.de
Wed Jun 23 02:09:31 CDT 2010


According to TestBot (#2851), all non-crashing Windows versions return 0.

Found while working on Bug 21012. Although this patch doesn't cure this
bug, I think it is still worth adding the check because the pointer
may come from the (always evil ;)) user-application.

Signed-off-by: Wolfram Sang <wolfram at the-dreams.de>
---
 dlls/user32/cursoricon.c       |    4 ++++
 dlls/user32/tests/cursoricon.c |    5 +++++
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c
index 9a1810e..1cabb84 100644
--- a/dlls/user32/cursoricon.c
+++ b/dlls/user32/cursoricon.c
@@ -884,6 +884,10 @@ static HICON CURSORICON_CreateIconFromBMI( BITMAPINFO *bmi,
         return 0;
     }
 
+    /* A few Windows versions crash getting NULL, but most simply return it */
+    if (!bmi)
+        return 0;
+
     /* Check bitmap header */
 
     if ( (bmi->bmiHeader.biSize != sizeof(BITMAPCOREHEADER)) &&
diff --git a/dlls/user32/tests/cursoricon.c b/dlls/user32/tests/cursoricon.c
index b2e1d84..e81e76d 100644
--- a/dlls/user32/tests/cursoricon.c
+++ b/dlls/user32/tests/cursoricon.c
@@ -1005,6 +1005,11 @@ static void test_CreateIconFromResource(void)
     error = GetLastError();
     ok(error == 0xdeadbeef, "Last error: %u\n", error);
 
+    /* Rejection of NULL pointer crashes at least on WNT4WSSP6, W2KPROSP4, WXPPROSP3
+     *
+     * handle = CreateIconFromResource(NULL, ICON_RES_SIZE, TRUE, 0x00030000);
+     * ok(handle == NULL, "Invalid pointer accepted (%p)\n", handle);
+     */
     HeapFree(GetProcessHeap(), 0, hotspot);
 }
 
-- 
1.7.1




More information about the wine-patches mailing list