From a3b931e7c4a5702da5fd99df0746f9ff511b7fdc Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 28 May 2019 11:53:05 +0200 Subject: [PATCH] Construct from an array instead of assigning just past a string's end MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Assigning past the end used to be supported, but isn't a good way to do the job. Exposed by a qtxmlpatterns test that exercised this code, which gets a warning thanks to Giuseppe's recent changes to QCharRef. Task-number: QTBUG-76070 Change-Id: Ic254c7ffce60e3b2aafce76ab03ea5db8c68fafc Reviewed-by: Giuseppe D'Angelo Reviewed-by: MÃ¥rten Nordheim --- src/network/access/qftp.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/network/access/qftp.cpp b/src/network/access/qftp.cpp index b6b721030b..cc230a5411 100644 --- a/src/network/access/qftp.cpp +++ b/src/network/access/qftp.cpp @@ -955,11 +955,9 @@ void QFtpPI::readyRead() } } } - QString endOfMultiLine; - endOfMultiLine[0] = '0' + replyCode[0]; - endOfMultiLine[1] = '0' + replyCode[1]; - endOfMultiLine[2] = '0' + replyCode[2]; - endOfMultiLine[3] = QLatin1Char(' '); + const char count[4] = { char('0' + replyCode[0]), char('0' + replyCode[1]), + char('0' + replyCode[2]), char(' ') }; + QString endOfMultiLine(QLatin1String(count, 4)); QString lineCont(endOfMultiLine); lineCont[3] = QLatin1Char('-'); QStringRef lineLeft4 = line.leftRef(4);