diff --git a/src/gui/text/qtextmarkdownwriter.cpp b/src/gui/text/qtextmarkdownwriter.cpp index cda1f209ad6..a5d8f4cc976 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;