From 8b2beb2ebe13321d5d624047ecf0d8e949a8b9b8 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Sun, 24 Dec 2023 17:46:44 +0330 Subject: [PATCH] LibLine: Use the correct loop conditions for erase_character_forwards() Prior to this commit, the loop would continue forever and try to remove the same index every time, eventually hitting a VERIFY and crashing. --- Userland/Libraries/LibLine/InternalFunctions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibLine/InternalFunctions.cpp b/Userland/Libraries/LibLine/InternalFunctions.cpp index 20cfc674e9..12754d4e08 100644 --- a/Userland/Libraries/LibLine/InternalFunctions.cpp +++ b/Userland/Libraries/LibLine/InternalFunctions.cpp @@ -168,7 +168,7 @@ void Editor::erase_character_forwards() auto end_of_next_grapheme = closest_cursor_left_offset + 1 >= m_cached_buffer_metrics.grapheme_breaks.size() ? m_buffer.size() : m_cached_buffer_metrics.grapheme_breaks[closest_cursor_left_offset + 1]; - for (; m_cursor < end_of_next_grapheme;) + for (auto cursor = m_cursor; cursor < end_of_next_grapheme; ++cursor) remove_at_index(m_cursor); m_refresh_needed = true; }