From d902a16454faa1ac5b1648eb30feeef06008019c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 11 Aug 2022 14:50:46 +0200 Subject: [PATCH] QString: fix arg() for >2Gi repeated lowest-escape-sequence-numbers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Building on 15a80cf8a9d59203f8e2b436a5c804197c044807, this patch fixes the case where there are more than INT_MAX occurrences of the lowest-escape-sequence number, as in QString("%0").repeated(qsizetype(INT_MAX) + 1).arg(42); by replacing the corresponding int variables with qsizetype ones. Task-number: QTBUG-103531 Change-Id: I6f4593a86d8d605031bc1d6520a247676091b2c2 Reviewed-by: MÃ¥rten Nordheim (cherry picked from commit 32c0d32a4fef615a717d4950361dce361fc1e08b) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/text/qstring.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 725f38cf579..373792bece6 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -7947,9 +7947,9 @@ static void checkArgEscape(QStringView s) struct ArgEscapeData { int min_escape; // lowest escape sequence number - int occurrences; // number of occurrences of the lowest escape sequence number - int locale_occurrences; // number of occurrences of the lowest escape sequence number that - // contain 'L' + qsizetype occurrences; // number of occurrences of the lowest escape sequence number + qsizetype locale_occurrences; // number of occurrences of the lowest escape sequence number that + // contain 'L' qsizetype escape_len; // total length of escape sequences which will be replaced }; @@ -8042,7 +8042,7 @@ static QString replaceArgEscapes(QStringView s, const ArgEscapeData &d, qsizetyp QString result(result_len, Qt::Uninitialized); QChar *rc = const_cast(result.unicode()); QChar *const result_end = rc + result_len; - int repl_cnt = 0; + qsizetype repl_cnt = 0; const QChar *c = s.begin(); const QChar *const uc_end = s.end();