From 507ad1954f6fa4a9915931e07ca4e468b87ef470 Mon Sep 17 00:00:00 2001 From: Conor Byrne <71222289+cbyrneee@users.noreply.github.com> Date: Thu, 30 Dec 2021 16:16:08 +0000 Subject: [PATCH] HackStudio: Fix crash when clicking unstaged files In certain cases, an index might be invalid in the unstaged files view. We must check if this index is valid before attempting to read the index's data. --- Userland/DevTools/HackStudio/Git/GitWidget.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Userland/DevTools/HackStudio/Git/GitWidget.cpp b/Userland/DevTools/HackStudio/Git/GitWidget.cpp index 199b38ba03e..df86faddca2 100644 --- a/Userland/DevTools/HackStudio/Git/GitWidget.cpp +++ b/Userland/DevTools/HackStudio/Git/GitWidget.cpp @@ -45,6 +45,9 @@ GitWidget::GitWidget(const LexicalPath& repo_root) Gfx::Bitmap::try_load_from_file("/res/icons/16x16/plus.png").release_value_but_fixme_should_propagate_errors()); m_unstaged_files->on_selection_change = [this] { const auto& index = m_unstaged_files->selection().first(); + if (!index.is_valid()) + return; + const auto& selected = index.data().as_string(); show_diff(LexicalPath(selected)); };