Construct from an array instead of assigning just past a string's end

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 <giuseppe.dangelo@kdab.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Edward Welbourne 2019-05-28 11:53:05 +02:00
parent 3af85b92d7
commit a3b931e7c4
1 changed files with 3 additions and 5 deletions

View File

@ -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);