From 0224fa942b93c8bfed64c2388c28afbc57520a47 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Mon, 9 Jun 2025 21:44:34 -0700 Subject: [PATCH] io/fileview: use deleteLater() to delete file watchers Fixes crashes when writing a file while watching it. --- src/io/fileview.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/io/fileview.cpp b/src/io/fileview.cpp index e2c841e0..b6e911f9 100644 --- a/src/io/fileview.cpp +++ b/src/io/fileview.cpp @@ -490,7 +490,9 @@ void FileView::updatePath() { } void FileView::updateWatchedFiles() { - delete this->watcher; + // If inotify events are sent to the watcher after deletion and deleteLater + // isn't used, a use after free in the QML engine will occur. + if (this->watcher) this->watcher->deleteLater(); if (!this->targetPath.isEmpty() && this->bWatchChanges) { qCDebug(logFileView) << "Creating watcher for" << this << "at" << this->targetPath;