From 6f51b766c9dd8563d4fa736e6d229f1ac2c2ec36 Mon Sep 17 00:00:00 2001 From: Fabian Vogt Date: Wed, 16 Sep 2020 15:11:54 +0200 Subject: [PATCH] Don't crash ksmserver if restoreSession is called twice The connection to the lambda persists, so when it's called a second time, the lambda is also called twice, eventually resulting in a nullptr deref as m_restoreSessionCall is empty. --- ksmserver/server.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ksmserver/server.cpp b/ksmserver/server.cpp index 29e6b914f..501cfbc3f 100644 --- a/ksmserver/server.cpp +++ b/ksmserver/server.cpp @@ -694,6 +694,11 @@ KSMServer::KSMServer(InitFlags flags) connect(&protectionTimer, &QTimer::timeout, this, &KSMServer::protectionTimeout); connect(&restoreTimer, &QTimer::timeout, this, &KSMServer::tryRestoreNext); + connect(this, &KSMServer::sessionRestored, this, [this]() { + auto reply = m_restoreSessionCall.createReply(); + QDBusConnection::sessionBus().send(reply); + m_restoreSessionCall = QDBusMessage(); + }); connect(qApp, &QApplication::aboutToQuit, this, &KSMServer::cleanUp); setupXIOErrorHandler(); @@ -1029,11 +1034,6 @@ void KSMServer::restoreSession() lastAppStarted = 0; lastIdStarted.clear(); state = KSMServer::Restoring; - connect(this, &KSMServer::sessionRestored, this, [this]() { - auto reply = m_restoreSessionCall.createReply(); - QDBusConnection::sessionBus().send(reply); - m_restoreSessionCall = QDBusMessage(); - }); tryRestoreNext(); }