Skip to content

Commit 533b7a6

Browse files
committed
networking: fix UAFs in NMWirelessNetwork ap/setting destroy handler
1 parent a611932 commit 533b7a6

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

changelog/next.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
- QsWindow.updatesEnabled makes sure windows are redrawn when set to true.
99
- Fixed potential crashes from usage of `WindowsetProjection.screens` during monitor unplug.
1010
- Fixed crashes from accessing freed objects laundered through a `ScriptModel`.
11+
- Fixed crashes when a wifi network disappear s.

src/network/nm/network.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ void NMNetwork::addSettings(NMSettings* settings) {
7272

7373
auto onDestroyed = [this, settings]() {
7474
if (this->mSettings.take(settings->path())) {
75-
emit this->settingsRemoved(settings);
7675
this->updateReferenceSettings();
7776
if (this->mSettings.isEmpty()) this->bKnown = false;
77+
// Deletes `this`
78+
emit this->settingsRemoved(settings);
7879
}
7980
};
8081
QObject::connect(settings, &NMSettings::destroyed, this, onDestroyed);
@@ -240,8 +241,9 @@ void NMWirelessNetwork::addAccessPoint(NMAccessPoint* ap) {
240241
this->mAccessPoints.insert(ap->path(), ap);
241242
auto onDestroyed = [this, ap]() {
242243
if (this->mAccessPoints.take(ap->path())) {
243-
emit this->apRemoved(ap);
244244
this->updateReferenceAp();
245+
// Deletes `this`
246+
emit this->apRemoved(ap);
245247
}
246248
};
247249
// clang-format off

0 commit comments

Comments
 (0)