From: Wolfram Sang Date: Wed, 4 Aug 2010 14:05:00 +0000 (+0200) Subject: user32: Check for valid pointer in CreateIconFromResource. X-Git-Tag: wine-1.3.1~185 X-Git-Url: http://git.etersoft.ru/projects/?a=commitdiff_plain;h=9f0f17f8535879ed4807226062310e0858207026;p=wine%2Feterwine.git user32: Check for valid pointer in CreateIconFromResource. --- diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c index 9a1810e22a..938f0dd222 100644 --- a/dlls/user32/cursoricon.c +++ b/dlls/user32/cursoricon.c @@ -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; diff --git a/dlls/user32/tests/cursoricon.c b/dlls/user32/tests/cursoricon.c index b2e1d842aa..e81e76dd92 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); }