On Fri, 9 Sep 2005 15:09:24 -0400
"Dimi Paun" <[EMAIL PROTECTED]> wrote:

> From: "Phil Krylov" <[EMAIL PROTECTED]>
> > OK, should we then make a patch which adds an IsWindow() check after every
> > notification in every control? This one fixes a really annoying bug, while
> > the other places are not proved to crash.
> 
> Well, if it's a entire class of bugs, we should fix them all.

I think that we should check if it's a class of bugs or a single bug first.

> I guess we need a bit of experimentation on windows to see
> if we need to protect all notifications or only a few ones.

> I guess we can protect all of them, in which case we have
> to look to see how we can do it centrally, in the notification
> function itself.

I don't see a way to do it clean enough.

So, here's a new version of the patch (enhanced comment, WARN changed to a
TRACE).


ChangeLog:

Protect against wrong memory access if a listview is destroyed during
processing of its NM_DBLCLK notification (a.k.a. file dialog GPF).

-- Ph.
Index: dlls/comctl32/listview.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/listview.c,v
retrieving revision 1.429
diff -p -u -r1.429 listview.c
--- dlls/comctl32/listview.c	30 Aug 2005 10:07:17 -0000	1.429
+++ dlls/comctl32/listview.c	12 Sep 2005 22:10:51 -0000
@@ -8083,6 +8083,7 @@ static LRESULT LISTVIEW_KillFocus(LISTVI
 static LRESULT LISTVIEW_LButtonDblClk(LISTVIEW_INFO *infoPtr, WORD wKey, INT x, INT y)
 {
     LVHITTESTINFO htInfo;
+    HWND hwnd = infoPtr->hwndSelf;
 
     TRACE("(key=%hu, X=%hu, Y=%hu)\n", wKey, x, y);
 
@@ -8095,7 +8096,17 @@ static LRESULT LISTVIEW_LButtonDblClk(LI
     /* send NM_DBLCLK notification */
     LISTVIEW_HitTest(infoPtr, &htInfo, TRUE, FALSE);
     notify_click(infoPtr, NM_DBLCLK, &htInfo);
-
+    
+    /* If during NM_DBLCLK processing the listview was destroyed (e.g. in a
+     * shell browser control, native as well), don't try to continue execution,
+     * it's unsafe.
+     * TODO: Check if it is a whole class of bugs. */
+    if (!IsWindow(hwnd))
+    {
+        TRACE("destroyed during NM_DBLCLK processing\n");
+        return 0;
+    }
+    
     /* To send the LVN_ITEMACTIVATE, it must be on an Item */
     if(htInfo.iItem != -1) notify_itemactivate(infoPtr,&htInfo);
 


Reply via email to