ui/winui/icons.cpp

branch
newapi
changeset 218
d06e7e8e53e1
parent 217
b9798109c7d2
--- a/ui/winui/icons.cpp	Sat Oct 14 10:01:22 2023 +0200
+++ b/ui/winui/icons.cpp	Sat Oct 14 10:55:11 2023 +0200
@@ -348,6 +348,8 @@
 
 		// convert icon to (gdi) bitmap
 		ICONINFO info;
+		info.hbmColor = nullptr;
+		info.hbmMask = nullptr;
 		if (GetIconInfo(hicon, &info)) {
 			BITMAP bitmap;
 			if (GetObjectW(info.hbmColor, sizeof(BITMAP), &bitmap) != 0) {
@@ -361,11 +363,15 @@
 					memcpy(wb_data, bitmap_data, bitmap_size);
 					wbitmap = wb;
 				}
-				DeleteObject(info.hbmColor);
 				free(bitmap_data);
 			}
+			if (info.hbmMask) {
+				DeleteObject(info.hbmMask);
+			}
+			if (info.hbmColor) {
+				DeleteObject(info.hbmColor);
+			}
 		}
-		DeleteObject(info.hbmMask);
 
 		DestroyIcon(hicon_small);
 		DestroyIcon(hicon_large);

mercurial