user32: Check for valid pointer in CreateIconFromResource.
authorWolfram Sang <wolfram@the-dreams.de>
Wed, 4 Aug 2010 14:05:00 +0000 (16:05 +0200)
committerAlexandre Julliard <julliard@winehq.org>
Tue, 17 Aug 2010 12:18:45 +0000 (14:18 +0200)
dlls/user32/cursoricon.c
dlls/user32/tests/cursoricon.c

index 9a1810e22a1a77c698a14e0d6a9a33c5d036bce0..938f0dd22271fc50da585391f8ab54cd9e095d53 100644 (file)
@@ -1064,8 +1064,6 @@ static HCURSOR CURSORICON_CreateIconFromANI( const LPBYTE bits, DWORD bits_size,
 
     TRACE("bits %p, bits_size %d\n", bits, bits_size);
 
-    if (!bits) return 0;
-
     riff_find_chunk( ANI_ACON_ID, ANI_RIFF_ID, &root_chunk, &ACON_chunk );
     if (!ACON_chunk.data)
     {
@@ -1104,6 +1102,7 @@ static HCURSOR CURSORICON_CreateIconFromANI( const LPBYTE bits, DWORD bits_size,
         width, height, depth );
 
     frame_bits = HeapAlloc( GetProcessHeap(), 0, entry->dwDIBSize );
+    if (!frame_bits) return 0;
     memcpy( frame_bits, icon_data + entry->dwDIBOffset, entry->dwDIBSize );
 
     if (!header.width || !header.height)
@@ -1142,6 +1141,8 @@ HICON WINAPI CreateIconFromResourceEx( LPBYTE bits, UINT cbSize,
                    bits, cbSize, dwVersion, width, height,
                    bIcon ? "icon" : "cursor", (cFlag & LR_MONOCHROME) ? "mono" : "" );
 
+    if (!bits) return 0;
+
     if (bIcon)
     {
         hotspot.x = width / 2;
index b2e1d842aa32761e4ae3b4bd69f36e4cab41a679..e81e76dd920da9abd972fd33753ff81361271dea 100644 (file)
@@ -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);
 }