shell32: Avoid leaking icon handles.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Huw Davies 2017-04-19 13:13:39 +01:00 committed by Alexandre Julliard
parent c7c8d24bf9
commit 524e316a14
1 changed files with 10 additions and 2 deletions

View File

@ -305,10 +305,12 @@ static INT SIC_IconAppend (LPCWSTR sSourceFile, INT dwSourceIndex, HICON hSmallI
* gets small/big icon by number from a file * gets small/big icon by number from a file
*/ */
static INT SIC_LoadIcon (LPCWSTR sSourceFile, INT dwSourceIndex, DWORD dwFlags) static INT SIC_LoadIcon (LPCWSTR sSourceFile, INT dwSourceIndex, DWORD dwFlags)
{ HICON hiconLarge=0; {
HICON hiconLarge=0;
HICON hiconSmall=0; HICON hiconSmall=0;
HICON hiconLargeShortcut; HICON hiconLargeShortcut;
HICON hiconSmallShortcut; HICON hiconSmallShortcut;
int ret;
PrivateExtractIconsW( sSourceFile, dwSourceIndex, GetSystemMetrics(SM_CXICON), PrivateExtractIconsW( sSourceFile, dwSourceIndex, GetSystemMetrics(SM_CXICON),
GetSystemMetrics(SM_CYICON), &hiconLarge, 0, 1, 0 ); GetSystemMetrics(SM_CYICON), &hiconLarge, 0, 1, 0 );
@ -327,6 +329,8 @@ static INT SIC_LoadIcon (LPCWSTR sSourceFile, INT dwSourceIndex, DWORD dwFlags)
hiconSmallShortcut = SIC_OverlayShortcutImage(hiconSmall, FALSE); hiconSmallShortcut = SIC_OverlayShortcutImage(hiconSmall, FALSE);
if (NULL != hiconLargeShortcut && NULL != hiconSmallShortcut) if (NULL != hiconLargeShortcut && NULL != hiconSmallShortcut)
{ {
DestroyIcon( hiconLarge );
DestroyIcon( hiconSmall );
hiconLarge = hiconLargeShortcut; hiconLarge = hiconLargeShortcut;
hiconSmall = hiconSmallShortcut; hiconSmall = hiconSmallShortcut;
} }
@ -339,8 +343,12 @@ static INT SIC_LoadIcon (LPCWSTR sSourceFile, INT dwSourceIndex, DWORD dwFlags)
} }
} }
return SIC_IconAppend (sSourceFile, dwSourceIndex, hiconSmall, hiconLarge, dwFlags); ret = SIC_IconAppend( sSourceFile, dwSourceIndex, hiconSmall, hiconLarge, dwFlags );
DestroyIcon( hiconLarge );
DestroyIcon( hiconSmall );
return ret;
} }
/***************************************************************************** /*****************************************************************************
* SIC_Initialize [internal] * SIC_Initialize [internal]
*/ */