summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-05-12 15:04:12 +0200
committerAndreas Kling <kling@serenityos.org>2020-05-12 15:09:54 +0200
commit18ff75e67bab9ea840bd57fcd6ef33f9275eb9dc (patch)
treeb20f4af06bcc2cc9ebef8b16e5fc6e9eaa766782
parent575b6740816c49c8fbbfd8f63bd5bed0a0fdbb0c (diff)
downloadserenity-18ff75e67bab9ea840bd57fcd6ef33f9275eb9dc.zip
HackStudio: Don't crash when navigating backtrace with up/down keys
It's up to BacktraceModel::index() to validate its inputs.
-rw-r--r--DevTools/HackStudio/Debugger/BacktraceModel.cpp7
-rw-r--r--DevTools/HackStudio/Debugger/BacktraceModel.h2
2 files changed, 8 insertions, 1 deletions
diff --git a/DevTools/HackStudio/Debugger/BacktraceModel.cpp b/DevTools/HackStudio/Debugger/BacktraceModel.cpp
index 1e1c86c6a0..8cbd82627c 100644
--- a/DevTools/HackStudio/Debugger/BacktraceModel.cpp
+++ b/DevTools/HackStudio/Debugger/BacktraceModel.cpp
@@ -41,6 +41,13 @@ GUI::Variant BacktraceModel::data(const GUI::ModelIndex& index, Role role) const
return {};
}
+GUI::ModelIndex BacktraceModel::index(int row, int column, const GUI::ModelIndex&) const
+{
+ if (row < 0 || row >= static_cast<int>(m_frames.size()))
+ return {};
+ return create_index(row, column, &m_frames.at(row));
+}
+
Vector<BacktraceModel::FrameInfo> BacktraceModel::create_backtrace(const DebugSession& debug_session, const PtraceRegisters& regs)
{
u32 current_ebp = regs.ebp;
diff --git a/DevTools/HackStudio/Debugger/BacktraceModel.h b/DevTools/HackStudio/Debugger/BacktraceModel.h
index bc54c758d3..e55bfd0bc1 100644
--- a/DevTools/HackStudio/Debugger/BacktraceModel.h
+++ b/DevTools/HackStudio/Debugger/BacktraceModel.h
@@ -47,7 +47,7 @@ public:
virtual GUI::Variant data(const GUI::ModelIndex& index, Role role = Role::Display) const override;
virtual void update() override {}
- virtual GUI::ModelIndex index(int row, int column = 0, const GUI::ModelIndex& = GUI::ModelIndex()) const override { return create_index(row, column, &m_frames.at(row)); }
+ virtual GUI::ModelIndex index(int row, int column, const GUI::ModelIndex&) const override;
struct FrameInfo {
String function_name;