summaryrefslogtreecommitdiffstats
path: root/src/dbus
diff options
context:
space:
mode:
authorIevgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>2023-09-08 16:26:23 +0200
committerIevgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>2023-09-18 15:50:43 +0200
commiteacff46af4216d0482c304aaf3d0d2e69368feeb (patch)
treed1591057d07ee680ead13c39cd9b3983bb80e48e /src/dbus
parent215677818470e48e9090d7ae4411e1fea62207b8 (diff)
QtDBus: Check if QDBusServer is destroyed before accessing it
Also lock before accessing serverObject member, it is cleared by ~QDBusServer(). Task-number: QTBUG-116621 Change-Id: I14c96e34316a46fe43ecd929e44cd1800ba8b803 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/dbus')
-rw-r--r--src/dbus/qdbusintegrator.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp
index 276a3fcc3f..e0478d0d48 100644
--- a/src/dbus/qdbusintegrator.cpp
+++ b/src/dbus/qdbusintegrator.cpp
@@ -313,6 +313,10 @@ static void qDBusNewConnection(DBusServer *server, DBusConnection *connection, v
newConnection->setPeer(connection, error);
newConnection->setDispatchEnabled(false);
+ QReadLocker serverLock(&serverConnection->lock);
+ if (!serverConnection->serverObject)
+ return;
+
// this is a queued connection and will resume in the QDBusServer's thread
QMetaObject::invokeMethod(serverConnection->serverObject, &QDBusServer::newConnection,
Qt::QueuedConnection, QDBusConnectionPrivate::q(newConnection));
@@ -321,7 +325,7 @@ static void qDBusNewConnection(DBusServer *server, DBusConnection *connection, v
// QDBusServer's thread in order to enable it after the
// QDBusServer::newConnection() signal has been received by the
// application's code
- QReadLocker serverLock(&serverConnection->lock);
+
newConnection->enableDispatchDelayed(serverConnection->serverObject);
}