fix major memleak

Andreas Mohr andi at rhlx01.fht-esslingen.de
Mon May 27 13:40:54 CDT 2002


Hi all,

this fixes a memleak in find_child_from_point().
It wasn't freeing the child window list in a lot of return cases.

This should resolve bug #590.
And I should be happy :-)

AbiWord, which was mentioned by the bug reporter in a mail,
doesn't eat mem on the toolbars any more...

-- 
Andreas Mohr                        Stauferstr. 6, D-71272 Renningen, Germany
-------------- next part --------------
Determining best CVS host...
Using CVSROOT :pserver:cvs at rhlx01.fht-esslingen.de:/home/wine
Index: windows/winpos.c
===================================================================
RCS file: /home/wine/wine/windows/winpos.c,v
retrieving revision 1.132
diff -u -r1.132 winpos.c
--- windows/winpos.c	6 Apr 2002 00:40:41 -0000	1.132
+++ windows/winpos.c	27 May 2002 18:36:32 -0000
@@ -327,6 +327,7 @@
     RECT rectWindow, rectClient;
     WND *wndPtr;
     HWND *list = WIN_ListChildren( parent );
+    HWND retvalue = 0;
 
     if (!list) return 0;
     for (i = 0; list[i]; i++)
@@ -362,12 +363,14 @@
         if (style & WS_MINIMIZE)
         {
             *hittest = HTCAPTION;
-            return list[i];
+            retvalue = list[i];
+	    goto end;
         }
         if (style & WS_DISABLED)
         {
             *hittest = HTERROR;
-            return list[i];
+            retvalue = list[i];
+	    goto end;
         }
 
         /* If point is in client area, explore children */
@@ -379,23 +382,30 @@
             new_pt.x = pt.x - rectClient.left;
             new_pt.y = pt.y - rectClient.top;
             if ((ret = find_child_from_point( list[i], new_pt, hittest, lparam )))
-                return ret;
+	    {
+                 retvalue = ret;
+		 goto end;
+	    }
         }
 
         /* Now it's inside window, send WM_NCCHITTEST (if same thread) */
         if (!WIN_IsCurrentThread( list[i] ))
         {
             *hittest = HTCLIENT;
-            return list[i];
+            retvalue = list[i];
+	    goto end;
         }
         if ((res = SendMessageA( list[i], WM_NCHITTEST, 0, lparam )) != HTTRANSPARENT)
         {
             *hittest = res;  /* Found the window */
-            return list[i];
+            retvalue = list[i];
+	    goto end;
         }
         /* continue search with next sibling */
     }
-    return 0;
+end:
+    if (list) HeapFree( GetProcessHeap(), 0, list );
+    return retvalue;
 }
 
 
@@ -418,8 +428,10 @@
     *hittest = HTERROR;
     if (style & WS_DISABLED) return 0;
 
+    TRACE("#1\n");
     MapWindowPoints( GetDesktopWindow(), GetAncestor( hwndScope, GA_PARENT ), &xy, 1 );
 
+    TRACE("#2\n");
     if (!(style & WS_MINIMIZE))
     {
         RECT rectClient;
@@ -427,6 +439,7 @@
         {
             HWND ret;
 
+    TRACE("#3\n");
             xy.x -= rectClient.left;
             xy.y -= rectClient.top;
             if ((ret = find_child_from_point( hwndScope, xy, hittest, MAKELONG( pt.x, pt.y ) )))
@@ -437,14 +450,18 @@
         }
     }
 
+    TRACE("#4\n");
     /* If nothing found, try the scope window */
     if (!WIN_IsCurrentThread( hwndScope ))
     {
+    TRACE("#5\n");
         *hittest = HTCLIENT;
         TRACE( "returning %x\n", hwndScope );
         return hwndScope;
     }
+    TRACE("#6\n");
     res = SendMessageA( hwndScope, WM_NCHITTEST, 0, MAKELONG( pt.x, pt.y ) );
+    TRACE("#7\n");
     if (res != HTTRANSPARENT)
     {
         *hittest = res;  /* Found the window */


More information about the wine-patches mailing list