https://git.reactos.org/?p=reactos.git;a=commitdiff;h=633d2e6d0cd4938dc6227c...
commit 633d2e6d0cd4938dc6227c22f30cc2fd81c673aa Author: Marek Benc benc.marek.elektro98@proton.me AuthorDate: Sat Aug 31 22:07:33 2024 +0200 Commit: GitHub noreply@github.com CommitDate: Sat Aug 31 15:07:33 2024 -0500
[NTUSER] Address memory leak in co_WinPosSetWindowPos(). (#7284)
CORE-19723 --- win32ss/user/ntuser/winpos.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-)
diff --git a/win32ss/user/ntuser/winpos.c b/win32ss/user/ntuser/winpos.c index 7256f59ad56..d06730112be 100644 --- a/win32ss/user/ntuser/winpos.c +++ b/win32ss/user/ntuser/winpos.c @@ -2071,11 +2071,6 @@ co_WinPosSetWindowPos( RgnType = IntGdiCombineRgn(CopyRgn, VisAfter, VisBeforeJustClient, RGN_AND); }
- if (VisBeforeJustClient != NULL) - { - REGION_Delete(VisBeforeJustClient); - } - /* Now use in copying bits which are in the update region. */ if (Window->hrgnUpdate != NULL) { @@ -2223,11 +2218,6 @@ co_WinPosSetWindowPos( } }
- if (CopyRgn != NULL) - { - REGION_Delete(CopyRgn); - } - /* Expose what was covered before but not covered anymore */ if (VisBefore != NULL) { @@ -2248,12 +2238,6 @@ co_WinPosSetWindowPos( } REGION_Delete(ExposedRgn); } - REGION_Delete(VisBefore); - } - - if (VisAfter != NULL) - { - REGION_Delete(VisAfter); } }
@@ -2301,6 +2285,27 @@ co_WinPosSetWindowPos( WinPos.flags |= SWP_NOZORDER|SWP_NOREDRAW; }
+ if (VisBefore != NULL) + { + REGION_Delete(VisBefore); + VisBefore = NULL; + } + if (VisBeforeJustClient != NULL) + { + REGION_Delete(VisBeforeJustClient); + VisBeforeJustClient = NULL; + } + if (VisAfter != NULL) + { + REGION_Delete(VisAfter); + VisAfter = NULL; + } + if (CopyRgn != NULL) + { + REGION_Delete(CopyRgn); + CopyRgn = NULL; + } + if(!(flags & SWP_DEFERERASE)) { /* erase parent when hiding or resizing child */