]> git.saurik.com Git - wxWidgets.git/commitdiff
attempt to fix crash in DeleteAllItems()
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 21 Jan 2003 18:56:31 +0000 (18:56 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 21 Jan 2003 18:56:31 +0000 (18:56 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18849 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/listctrl.cpp

index 15356ad7d985ae2b1e1eafc3096e0f6231b954c0..26633b3cc91e988e0c8e079c31ec6a7373c9362e 100644 (file)
@@ -1752,7 +1752,7 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
                     // there's a GPF in Windows.
                     // By returning TRUE here, we avoid further processing
                     // of this strange message.
-                    if (info->iItem > GetColumnCount())
+                    if ( info->iItem >= GetColumnCount() )
                         return TRUE;
                 }
                 // fall through
@@ -1779,8 +1779,32 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
             case LVN_COLUMNCLICK:
             case LVN_ITEMCHANGED:
             case LVN_ITEMCHANGING:
-                if ( iItem != -1 )
+                if ( item != -1 )
                 {
+                    if ( iItem >= GetItemCount() )
+                    {
+                        // there is apparently a bug in comctl32.dll version
+                        // 5.50.4704.1100 (note that the MS DLL database
+                        // doesn't say what this version is, it's not the one
+                        // shipped with W2K although the bug was reported under
+                        // that system) and it sends us LVN_ITEMCHANGING
+                        // notifications with the item out of range -- and as
+                        // we access the items client data, we crash below
+                        //
+                        // see
+                        //
+                        //  http://lists.wxwindows.org/cgi-bin/ezmlm-cgi?8:mss:29852:knlihdmadhaljafjajei
+                        //
+                        // and the thread continuation for more details
+                        // (although note that the bug may be present in other
+                        // versions of comctl32.dll as well as it has been
+                        // reported quite a few times)
+                        //
+                        // to fix this, simply ignore these "bad" events (as
+                        // above with HDN_GETDISPINFOW)
+                        return TRUE;
+                    }
+
                     wxListItemInternalData *internaldata =
                         (wxListItemInternalData *) nmLV->lParam;