Commit 4e633f92 authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

shell32/iconcache: Prevent the imagelists from going out of sync when loading an icon.

When populating the imagelists cache with icons of different sizes, it can happen that only some icon sizes actually succeed the extraction, with others failing with a NULL handle. This is especially true with some broken "executable packers" where for example, a 32x32 icon loads okay, but a 16x16 fails. Even when PrivateExtractIconsW succeeds, the returned handle can still be NULL, leading to the ImageLists becoming out of sync. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45696Signed-off-by: 's avatarGabriel Ivăncescu <gabrielopcode@gmail.com> Signed-off-by: 's avatarHuw Davies <huw@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 161d02fd
......@@ -364,13 +364,14 @@ static INT SIC_LoadIcon (const WCHAR *sourcefile, INT index, DWORD flags)
HICON hshortcuts[ARRAY_SIZE(hicons)] = { 0 };
unsigned int i;
SIZE size;
int ret;
INT ret = -1;
for (i = 0; i < ARRAY_SIZE(hicons); i++)
{
get_imagelist_icon_size( i, &size );
if (!PrivateExtractIconsW( sourcefile, index, size.cx, size.cy, &hicons[i], 0, 1, 0 ))
WARN("Failed to load icon %d from %s.\n", index, debugstr_w(sourcefile));
if (!hicons[i]) goto fail;
}
if (flags & GIL_FORSHORTCUT)
......@@ -403,6 +404,8 @@ static INT SIC_LoadIcon (const WCHAR *sourcefile, INT index, DWORD flags)
}
ret = SIC_IconAppend( sourcefile, index, hicons, flags );
fail:
for (i = 0; i < ARRAY_SIZE(hicons); i++)
DestroyIcon(hicons[i]);
return ret;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment