[PATCH 2/2] user32: Delete info.hbmColor and hbmMask after copying.

Stefan Dösinger stefan at codeweavers.com
Thu Jun 10 09:12:20 CDT 2021


Signed-off-by: Stefan Dösinger <stefan at codeweavers.com>

---

Fixes a handle leak in explorer.exe when an application repeatedly redraws the systray
icon introduced by 5df5972f9aac.

GetIconInfoExW returns a copy, CopyImage does not take ownership, so we
have to relese them.
---
 dlls/user32/cursoricon.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c
index f820c10a0d8..7ad0a04a551 100644
--- a/dlls/user32/cursoricon.c
+++ b/dlls/user32/cursoricon.c
@@ -1670,12 +1670,16 @@ HICON WINAPI CreateIcon( HINSTANCE instance, int width, int height, BYTE planes,
 HICON WINAPI CopyIcon( HICON icon )
 {
     ICONINFOEXW info;
+    HICON res;
 
     info.cbSize = sizeof(info);
     if (!GetIconInfoExW( icon, &info ))
         return NULL;
 
-    return CopyImage( icon, info.fIcon ? IMAGE_ICON : IMAGE_CURSOR, 0, 0, 0 );
+    res = CopyImage( icon, info.fIcon ? IMAGE_ICON : IMAGE_CURSOR, 0, 0, 0 );
+    DeleteObject( info.hbmColor );
+    DeleteObject( info.hbmMask );
+    return res;
 }
 
 
-- 
2.31.1




More information about the wine-devel mailing list