summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-12-20 10:38:46 +0100
committerMarc Mutz <marc.mutz@qt.io>2023-12-20 10:57:14 +0100
commit4ef440b458c526ad24a3e87d480ddb44c76c6438 (patch)
tree010dbdf03fd10cc9e087b017d6c15eb12bc5bf57
parent19870e5df01e0c47294b7f9cd839191d6762fb63 (diff)
QConnectedReplicaImplementation: don't call deleteLater() on a nullptr
It's undefined behavior according to C++, even if you don't touch members, and only happened to work until qtbase/13074a967f18ed348ab744f7ff831965607a6421 which made it stop "working". Add an explicit nullptr check before calling deleteLater(). Amends 35dd08098f8a4b422d523792261aefe039358f6a(!). Fixes: QTBUG-120242 Pick-to: 6.7 6.6 6.5 6.2 5.15 Change-Id: I9ce95f8c8f917549ccfd0040f0cd4f483c3a28d0 Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
-rw-r--r--src/remoteobjects/qremoteobjectreplica.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/remoteobjects/qremoteobjectreplica.cpp b/src/remoteobjects/qremoteobjectreplica.cpp
index d09c157..77ab478 100644
--- a/src/remoteobjects/qremoteobjectreplica.cpp
+++ b/src/remoteobjects/qremoteobjectreplica.cpp
@@ -119,8 +119,10 @@ QConnectedReplicaImplementation::~QConnectedReplicaImplementation()
sendCommand();
}
for (auto prop : m_propertyStorage) {
- if (prop.canConvert<QObject*>())
- prop.value<QObject *>()->deleteLater();
+ if (prop.canConvert<QObject*>()) {
+ if (auto o = prop.value<QObject*>())
+ o->deleteLater();
+ }
}
}