From ce1c6096d3e426a3005fadc424779d2400971c40 Mon Sep 17 00:00:00 2001 From: Akseli Lahtinen Date: Wed, 8 May 2024 19:41:39 +0000 Subject: [PATCH] Check for tagToken length Sometimes this part of the code causes segfault for me. I don't know what the root cause is though, it's *very* random. I guess the tagToken should always be long enough, but sometimes it's just one character. --- src/texthandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/texthandler.cpp b/src/texthandler.cpp index 0b6dd8e76..f2c706e46 100644 --- a/src/texthandler.cpp +++ b/src/texthandler.cpp @@ -389,7 +389,7 @@ QString TextHandler::stripBlockTags(QString string, const QString &tagType) cons QString TextHandler::getTagType(const QString &tagToken) const { - if (tagToken.isEmpty()) { + if (tagToken.isEmpty() || tagToken.length() < 2) { return QString(); } const int tagTypeStart = tagToken[1] == u'/' ? 2 : 1;