From 34d39c9dfb17771afc0994221933c69a7c2f702a Mon Sep 17 00:00:00 2001 From: David Hart Date: Fri, 19 Aug 2016 23:19:14 +0200 Subject: [PATCH] Fix use of dangling reference in wxFileSystemWatcher Unix code Don't reference the "watch" object after possibly destroying it when handling IN_DELETE_SELF inotify notification. Closes #17122. --- docs/changes.txt | 1 + src/unix/fswatcher_inotify.cpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index 4c5f58fe8e..18fd73447c 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -107,6 +107,7 @@ wxGTK: - Improve wxSpinCtrl best size calculation. - Implement support for icon locations in wxMimeTypesManager (Hanmac). - Cosmetic fix for empty wxCheckBoxes display (Chuddah). +- Fix crashes in wxFileSystemWatcher implementation (David Hart). wxMSW: diff --git a/src/unix/fswatcher_inotify.cpp b/src/unix/fswatcher_inotify.cpp index 681700d367..ae1e69096e 100644 --- a/src/unix/fswatcher_inotify.cpp +++ b/src/unix/fswatcher_inotify.cpp @@ -385,6 +385,7 @@ protected: // if the wd isn't found: repeated IN_DELETE_SELFs can occur wxFileName fn = GetEventPath(watch, inevt); wxString path(fn.GetPathWithSep()); + const wxString filespec(watch.GetFilespec()); if (m_watchMap.erase(inevt.wd) == 1) { @@ -406,7 +407,7 @@ protected: // Tell the owner, in case it's interested // If there's a filespec, assume he's not - if (watch.GetFilespec().empty()) + if (filespec.empty()) { wxFileSystemWatcherEvent event(flags, fn, fn); SendEvent(event);