From 09e5d80286276d4683c944dfa0cddda3479006c0 Mon Sep 17 00:00:00 2001
From: Mladen Milinkovic <maxrd2@smoothware.net>
Date: Thu, 19 Jan 2023 18:39:31 +0100
Subject: [PATCH] Subtitle: fixed crash in splitLines()

---
 src/core/subtitle.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/core/subtitle.cpp b/src/core/subtitle.cpp
index d3da532d..3359062e 100644
--- a/src/core/subtitle.cpp
+++ b/src/core/subtitle.cpp
@@ -541,7 +541,7 @@ Subtitle::splitLines(const RangeList &ranges)
 				c->insertText(QString(QChar::LineFeed));
 				return true;
 			}
-			if(text.at(j) == QChar::Space) {
+			if(j < len && text.at(j) == QChar::Space) {
 				c->movePosition(QTextCursor::Start);
 				c->movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, j);
 				c->movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor);
-- 
GitLab

