From: Gabriel Ivăncescu Subject: [PATCH 2/2] shell32/iconcache: Simplify and break as soon as one shortcut failed to overlay Message-Id: Date: Mon, 8 Oct 2018 21:51:15 +0300 In-Reply-To: <094f81391d8858be3e769cfaf6c61b95d80a4cb0.1539024513.git.gabrielopcode@gmail.com> References: <094f81391d8858be3e769cfaf6c61b95d80a4cb0.1539024513.git.gabrielopcode@gmail.com> There is no need to initialize and destroy shortcut icons that we haven't even processed. Signed-off-by: Gabriel Ivăncescu --- dlls/shell32/iconcache.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dlls/shell32/iconcache.c b/dlls/shell32/iconcache.c index 5ffb293..2e6e0ff 100644 --- a/dlls/shell32/iconcache.c +++ b/dlls/shell32/iconcache.c @@ -354,7 +354,6 @@ static INT SIC_IconAppend (const WCHAR *sourcefile, INT src_index, HICON *hicons static INT SIC_LoadIcon (const WCHAR *sourcefile, INT index, DWORD flags) { HICON hicons[ARRAY_SIZE(shell_imagelists)] = { 0 }; - HICON hshortcuts[ARRAY_SIZE(hicons)] = { 0 }; SIZE size[ARRAY_SIZE(shell_imagelists)]; unsigned int i; INT ret = -1; @@ -421,6 +420,7 @@ static INT SIC_LoadIcon (const WCHAR *sourcefile, INT index, DWORD flags) if (flags & GIL_FORSHORTCUT) { + HICON hshortcuts[ARRAY_SIZE(hicons)]; BOOL failed = FALSE; for (i = 0; i < ARRAY_SIZE(hshortcuts); i++) @@ -429,13 +429,15 @@ static INT SIC_LoadIcon (const WCHAR *sourcefile, INT index, DWORD flags) { WARN("Failed to create shortcut overlaid icons.\n"); failed = TRUE; + break; } } if (failed) { - for (i = 0; i < ARRAY_SIZE(hshortcuts); i++) - DestroyIcon(hshortcuts[i]); + unsigned int k; + for (k = 0; k < i; k++) + DestroyIcon(hshortcuts[k]); flags &= ~GIL_FORSHORTCUT; } else -- 1.9.1