From e758d8ad80a83fe30e6ff2bae0e15653e7c32402 Mon Sep 17 00:00:00 2001 From: Rick Date: Wed, 6 Dec 2023 11:52:45 +0100 Subject: [PATCH] Fix crash when processing renames in wxMSW wxFileSystemWatcher It could (and did, albeit rarely) happen that we read only the first of the couple events associated with a file rename and in this case the code crashed due to dereferencing invalid iterator. Ideal would be to delay sending the "renamed" event until we get the new path, but for now just fix the crash by not using the invalid iterator. Closes #24119. --- src/msw/fswatcher.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/msw/fswatcher.cpp b/src/msw/fswatcher.cpp index 6057ecc138..165a8948f3 100644 --- a/src/msw/fswatcher.cpp +++ b/src/msw/fswatcher.cpp @@ -349,6 +349,8 @@ void wxIOCPThread::ProcessNativeEvents(wxVector& events) } wxFileSystemWatcherEvent event(flags, oldpath, newpath); SendEvent(event); + if ( it == events.end() ) + break; } // all other events else