summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2022-09-09 22:35:24 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-09-10 16:50:43 +0000
commit9fe9c41f8377d4194108c69b3fc684532c630e9c (patch)
tree6c8ea7133da8a15a078eba521abc963dfd225f6f
parent185fdcad18f3b3e42cb02f5cf3f1925ec926d191 (diff)
Avoid crash in QTextMarkdownWriter::writeBlock()
The inner loop would go out of bounds whenever it tried to find the end of a run of spaces in a fragment that contained only spaces. Fixes: QTBUG-104999 Change-Id: I5dda03b31194fff12f6052c458a0eb85d0be5c2b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 9807c4e5afc953444a4b5a161ceb31c68fdf2484) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/gui/text/qtextmarkdownwriter.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/gui/text/qtextmarkdownwriter.cpp b/src/gui/text/qtextmarkdownwriter.cpp
index cda1f209ad..a5d8f4cc97 100644
--- a/src/gui/text/qtextmarkdownwriter.cpp
+++ b/src/gui/text/qtextmarkdownwriter.cpp
@@ -540,13 +540,13 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign
}
if (wrap && col + markers.length() * 2 + fragmentText.length() > ColumnLimit) {
int i = 0;
- int fragLen = fragmentText.length();
+ const int fragLen = fragmentText.length();
bool breakingLine = false;
while (i < fragLen) {
if (col >= ColumnLimit) {
m_stream << Newline << wrapIndentString;
col = m_wrappedLineIndent;
- while (fragmentText[i].isSpace())
+ while (i < fragLen && fragmentText[i].isSpace())
++i;
}
int j = i + ColumnLimit - col;