From ead3b00afdf603bb6d4c30fc9c9f582d8f712168 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Mon, 6 Jul 2026 23:27:24 -0700 Subject: [PATCH] networking: fix UAFs in NMWirelessNetwork ap/setting destroy handler --- changelog/next.md | 1 + src/network/nm/network.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/changelog/next.md b/changelog/next.md index f18fe30..0a146fd 100644 --- a/changelog/next.md +++ b/changelog/next.md @@ -8,3 +8,4 @@ - QsWindow.updatesEnabled makes sure windows are redrawn when set to true. - Fixed potential crashes from usage of `WindowsetProjection.screens` during monitor unplug. - Fixed crashes from accessing freed objects laundered through a `ScriptModel`. +- Fixed crashes when a wifi network disappear. diff --git a/src/network/nm/network.cpp b/src/network/nm/network.cpp index 945a438..a3e0ef9 100644 --- a/src/network/nm/network.cpp +++ b/src/network/nm/network.cpp @@ -72,9 +72,10 @@ void NMNetwork::addSettings(NMSettings* settings) { auto onDestroyed = [this, settings]() { if (this->mSettings.take(settings->path())) { - emit this->settingsRemoved(settings); this->updateReferenceSettings(); if (this->mSettings.isEmpty()) this->bKnown = false; + // Deletes `this` + emit this->settingsRemoved(settings); } }; QObject::connect(settings, &NMSettings::destroyed, this, onDestroyed); @@ -240,8 +241,9 @@ void NMWirelessNetwork::addAccessPoint(NMAccessPoint* ap) { this->mAccessPoints.insert(ap->path(), ap); auto onDestroyed = [this, ap]() { if (this->mAccessPoints.take(ap->path())) { - emit this->apRemoved(ap); this->updateReferenceAp(); + // Deletes `this` + emit this->apRemoved(ap); } }; // clang-format off