[PATCH 2/5] comctl32: Fix memory leaks.

Zhiyi Zhang zzhang at codeweavers.com
Sun Feb 28 21:09:48 CST 2021


Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
---
 dlls/comctl32/edit.c     | 7 ++++++-
 dlls/comctl32/listview.c | 1 +
 dlls/comctl32/treeview.c | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/dlls/comctl32/edit.c b/dlls/comctl32/edit.c
index f84ef1eb168..4ad46357d96 100644
--- a/dlls/comctl32/edit.c
+++ b/dlls/comctl32/edit.c
@@ -2514,7 +2514,10 @@ static void EDIT_EM_ReplaceSel(EDITSTATE *es, BOOL can_undo, const WCHAR *lpsz_r
 				abs(es->selection_end - es->selection_start) - strl, hrgn);
 			strl = 0;
 			e = s;
-			hrgn = CreateRectRgn(0, 0, 0, 0);
+                        if (hrgn)
+                            SetRectRgn(hrgn, 0, 0, 0, 0);
+                        else
+                            hrgn = CreateRectRgn(0, 0, 0, 0);
 			EDIT_NOTIFY_PARENT(es, EN_MAXTEXT);
 		}
 	}
@@ -3674,6 +3677,8 @@ static void EDIT_WM_NCPaint(HWND hwnd, HRGN region)
 
     /* Call default proc to get the scrollbars etc. also painted */
     DefWindowProcW (hwnd, WM_NCPAINT, (WPARAM)cliprgn, 0);
+    if (cliprgn != region)
+        DeleteObject(cliprgn);
 }
 
 /*********************************************************************
diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c
index 0c80b6164a9..0a05c0668ae 100644
--- a/dlls/comctl32/listview.c
+++ b/dlls/comctl32/listview.c
@@ -10645,6 +10645,7 @@ static BOOL LISTVIEW_NCPaint(const LISTVIEW_INFO *infoPtr, HRGN region)
 
     /* Call default proc to get the scrollbars etc. painted */
     DefWindowProcW (infoPtr->hwndSelf, WM_NCPAINT, (WPARAM)cliprgn, 0);
+    DeleteObject(cliprgn);
 
     return FALSE;
 }
diff --git a/dlls/comctl32/treeview.c b/dlls/comctl32/treeview.c
index 7f9a6f88cee..0e4a92a466f 100644
--- a/dlls/comctl32/treeview.c
+++ b/dlls/comctl32/treeview.c
@@ -5468,6 +5468,7 @@ static BOOL TREEVIEW_NCPaint (const TREEVIEW_INFO *infoPtr, HRGN region, LPARAM
 
     /* Call default proc to get the scrollbars etc. painted */
     DefWindowProcW (infoPtr->hwnd, WM_NCPAINT, (WPARAM)cliprgn, 0);
+    DeleteObject(cliprgn);
 
     return TRUE;
 }
-- 
2.27.0




More information about the wine-devel mailing list