From f70268ea4018212f5065190cc7b41d289911df7d Mon Sep 17 00:00:00 2001 From: paxcut Date: Thu, 19 Mar 2026 12:15:22 -0700 Subject: [PATCH] fixed crash when the marched delimiter near cursor becomes rii large if lines are removed. --- plugins/ui/source/ui/text_editor/navigate.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/ui/source/ui/text_editor/navigate.cpp b/plugins/ui/source/ui/text_editor/navigate.cpp index 67c8acc39..d43a4adce 100644 --- a/plugins/ui/source/ui/text_editor/navigate.cpp +++ b/plugins/ui/source/ui/text_editor/navigate.cpp @@ -646,6 +646,12 @@ namespace hex::ui { bool TextEditor::MatchedDelimiter::setNearCursor(Lines *lines,const Coordinates &from) { Coordinates fromCopy = from; + if (fromCopy.m_line >= lines->size()) + return false; + if (m_nearCursor.m_line >= lines->size()) { + m_nearCursor = Invalid; + return false; + } if (coordinatesNearDelimiter(lines, fromCopy)) { m_nearCursor = fromCopy; return true; @@ -718,6 +724,8 @@ namespace hex::ui { if (start == Invalid) return false; auto lineIndex = start.m_line; + if(lineIndex >= (i64) lines->size()) + return false; auto charIndex = lines->lineCoordsIndex(start); auto direction1 = detectDirection(lines, start); auto charCoords = lines->lineIndexCoords(lineIndex + 1, charIndex);