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.
wilder-portage-prov
Fabian Vogt 6 years ago
parent dbc1d4726c
commit 6f51b766c9
  1. 10
      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();
}

Loading…
Cancel
Save