Module: wine Branch: master Commit: 9f0f17f8535879ed4807226062310e0858207026 URL: http://source.winehq.org/git/wine.git/?a=commit;h=9f0f17f8535879ed4807226062...
Author: Wolfram Sang wolfram@the-dreams.de Date: Wed Aug 4 16:05:00 2010 +0200
user32: Check for valid pointer in CreateIconFromResource.
---
dlls/user32/cursoricon.c | 5 +++-- dlls/user32/tests/cursoricon.c | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c index 9a1810e..938f0dd 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 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); }