From a205633643a828557c34e19d234a8c996c1f4ee3 Mon Sep 17 00:00:00 2001 From: Maurice Hieronymus Date: Sun, 11 Jul 2021 18:28:16 +0200 Subject: [PATCH] HackStudio: Prevent crash when stepping through a program The backtrace view expects that there is always a valid selection. This is not true when we execute a step in the debugger. Therefore we need to check if we have a valid selection in the on_selection_change handler. --- Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp b/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp index e626ff8a2ac..f1842d78940 100644 --- a/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp +++ b/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp @@ -67,8 +67,12 @@ DebugInfoWidget::DebugInfoWidget() m_backtrace_view->on_selection_change = [this] { const auto& index = m_backtrace_view->selection().first(); - auto& model = static_cast(*m_backtrace_view->model()); + if (!index.is_valid()) { + return; + } + + auto& model = static_cast(*m_backtrace_view->model()); // Note: The reconstruction of the register set here is obviously incomplete. // We currently only reconstruct eip & ebp. Ideally would also reconstruct the other registers somehow. // (Other registers may be needed to get the values of variables who are not stored on the stack)