From 7c2941d4ea86c55ce8e2fe7b23d96be276c350c5 Mon Sep 17 00:00:00 2001 From: Itamar Date: Mon, 24 May 2021 22:54:23 +0300 Subject: [PATCH] LibGUI: Check that AutocompleteBox's selection row is valid Previously we didn't check that the selection's row index is in a valid range before attempting to access its data via the model. This could cause an out-of-bounds access to the model's Vector of suggestions. I think this should fix #7404, but I can't verify it does because I wasn't able to reproduce it on my machine. --- Userland/Libraries/LibGUI/AutocompleteProvider.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibGUI/AutocompleteProvider.cpp b/Userland/Libraries/LibGUI/AutocompleteProvider.cpp index d1798c31c2f..96370cb4b65 100644 --- a/Userland/Libraries/LibGUI/AutocompleteProvider.cpp +++ b/Userland/Libraries/LibGUI/AutocompleteProvider.cpp @@ -168,7 +168,7 @@ void AutocompleteBox::apply_suggestion() return; auto selected_index = m_suggestion_view->selection().first(); - if (!selected_index.is_valid()) + if (!selected_index.is_valid() || !m_suggestion_view->model()->is_valid(selected_index)) return; auto suggestion_index = m_suggestion_view->model()->index(selected_index.row(), AutocompleteSuggestionModel::Column::Name);