Explorar o código

LibWeb: Fix crash when skipping to previous word with ctrl+left arrow

Before this change, skipping a word to the left in a non empty text
input element would crash when near the end of the text as the
offset + length of the substring would exceed the length of the string.
Nathan van der Kamp hai 8 meses
pai
achega
1870f1a0a8
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      Libraries/LibWeb/HTML/FormAssociatedElement.cpp

+ 1 - 1
Libraries/LibWeb/HTML/FormAssociatedElement.cpp

@@ -794,7 +794,7 @@ void FormAssociatedTextControlElement::decrement_cursor_position_to_previous_wor
 
     while (true) {
         if (auto offset = text_node->word_segmenter().previous_boundary(m_selection_end); offset.has_value()) {
-            auto word = text_node->data().code_points().substring_view(m_selection_end, m_selection_end - *offset);
+            auto word = text_node->data().code_points().substring_view(*offset, m_selection_end - *offset);
             if (collapse == CollapseSelection::Yes) {
                 collapse_selection_to_offset(*offset);
             } else {