From c60e8303829be4f13fd4511eda3d4365572c74e6 Mon Sep 17 00:00:00 2001 From: Igor Kushnir Date: Sat, 15 Aug 2020 18:35:17 +0300 Subject: [PATCH] Check ICore::activeSession() for nullptr in BreakpointModel::save() When a user exits KDevelop while debugging a program, a queued call to BreakpointModel::save() may be invoked during Core::cleanup() or perhaps even during ~CorePrivate(). If this happens between SessionController::cleanup() and ~DebugController() (which is the parent of BreakpointModel), the result is a crash. A breakpoint change that is saved at this time is likely unimportant and can be safely skipped. BUG: 425986 FIXED-IN: 5.6.1 --- kdevplatform/debugger/breakpoint/breakpointmodel.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kdevplatform/debugger/breakpoint/breakpointmodel.cpp b/kdevplatform/debugger/breakpoint/breakpointmodel.cpp index f66fa23584..8ed3278593 100644 --- a/kdevplatform/debugger/breakpoint/breakpointmodel.cpp +++ b/kdevplatform/debugger/breakpoint/breakpointmodel.cpp @@ -574,7 +574,14 @@ void BreakpointModel::save() d->dirty = false; - KConfigGroup breakpoints = ICore::self()->activeSession()->config()->group("Breakpoints"); + auto* const activeSession = ICore::self()->activeSession(); + if (!activeSession) { + qCDebug(DEBUGGER) << "Cannot save breakpoints because there is no active session. " + "KDevelop must be exiting and already past SessionController::cleanup()."; + return; + } + + KConfigGroup breakpoints = activeSession->config()->group("Breakpoints"); breakpoints.writeEntry("number", d->breakpoints.count()); int i = 0; for (Breakpoint* b : qAsConst(d->breakpoints)) { -- GitLab