From e9280cba13096d8917ff2e6526d625b4ab1e0384 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 10 Dec 2020 18:35:59 +0100 Subject: [PATCH] HackStudio: Don't vend invalid indices from SearchResultsModel This fixes an assertion when clicking in the "find in files" search results table when there were no matches. --- DevTools/HackStudio/FindInFilesWidget.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/DevTools/HackStudio/FindInFilesWidget.cpp b/DevTools/HackStudio/FindInFilesWidget.cpp index fe3717adb9e..8491379013a 100644 --- a/DevTools/HackStudio/FindInFilesWidget.cpp +++ b/DevTools/HackStudio/FindInFilesWidget.cpp @@ -96,7 +96,14 @@ public: } 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_matches.at(row)); } + virtual GUI::ModelIndex index(int row, int column = 0, const GUI::ModelIndex& = GUI::ModelIndex()) const override + { + if (row < 0 || row >= (int)m_matches.size()) + return {}; + if (column < 0 || column >= Column::__Count) + return {}; + return create_index(row, column, &m_matches.at(row)); + } private: Vector m_matches;