From 0e2f4c50d3c7719115710d72d3ec006b0b719c5e Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Sat, 25 Jun 2022 19:06:59 +0430 Subject: [PATCH] Spreadsheet: Prevent OOB access to text editor buffer For some reason LibGUI sends two events for each edit, and one of them contains an OOB cursor if a character was deleted. This works around that for now. --- Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp index 330a3d14ed..dbc58e0519 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp @@ -383,6 +383,7 @@ void SpreadsheetWidget::try_generate_tip_for_input_expression(StringView source, m_inline_documentation_window->hide(); return; } + cursor_offset = min(cursor_offset, source.length()); auto maybe_function_and_argument = get_function_and_argument_index(source.substring_view(0, cursor_offset)); if (!maybe_function_and_argument.has_value()) { m_inline_documentation_window->hide();