diff options
author | Marc Mutz <marc.mutz@qt.io> | 2023-12-20 10:38:46 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-12-20 11:01:31 +0000 |
commit | 405812b7609fbaf2be2575175fabdc4fdc77c1f7 (patch) | |
tree | 83d81cca4b9fcb06d1f1f6f5a74c486950eb54b9 | |
parent | c53f5287252dca4476f16d5f70570ea9389f48ff (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.6 6.5 6.2 5.15
Change-Id: I9ce95f8c8f917549ccfd0040f0cd4f483c3a28d0
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
(cherry picked from commit 4ef440b458c526ad24a3e87d480ddb44c76c6438)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/remoteobjects/qremoteobjectreplica.cpp | 6 |
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(); + } } } |