From 54abc61af1cee67c6440856bc3fb27c4e5eff135 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 2 Aug 2021 17:46:49 +0200 Subject: [PATCH] replaceArgEscapes(): correct a comment and assert what it relies on Change-Id: I1d0c82b1cac0d59bd1fbda65f6a3e5be346b4c70 Reviewed-by: Marc Mutz Reviewed-by: Thiago Macieira --- src/corelib/text/qstring.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 53139869e2..e9b132f8e2 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -7783,9 +7783,10 @@ static QString replaceArgEscapes(QStringView s, const ArgEscapeData &d, qsizetyp const QChar *c = s.begin(); const QChar *const uc_end = s.end(); while (c != uc_end) { - /* We don't have to check if we run off the end of the string with c, - because as long as d.occurrences > 0 we KNOW there are valid escape - sequences. */ + Q_ASSERT(d.occurrences > repl_cnt); + /* We don't have to check increments of c against uc_end because, as + long as d.occurrences > repl_cnt, we KNOW there are valid escape + sequences remaining. */ const QChar *text_start = c;