user32: Check for valid pointer in CreateIconFromResource.

This commit is contained in:
Wolfram Sang 2010-08-04 16:05:00 +02:00 committed by Alexandre Julliard
parent e4bb3ae755
commit 9f0f17f853
2 changed files with 8 additions and 2 deletions

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

View File

@ -1005,6 +1005,11 @@ static void test_CreateIconFromResource(void)
error = GetLastError(); error = GetLastError();
ok(error == 0xdeadbeef, "Last error: %u\n", error); 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); HeapFree(GetProcessHeap(), 0, hotspot);
} }