From 333b40a12e82edb44ee472d7b95e533a99bb32d0 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 5 Oct 2021 08:33:17 -0700 Subject: QUtf32: fix bad assertion in convertFromUnicode Looks like it was copied from QUtf16::convertFromUnicode(), but for the UTF-32 case that is not correct. UTF-16 to UTF-32 conversions can change the length of the string due to surrogates. There are unit test tests for creating and parsing UTF-32 headers, and for detecting content as UTF-32, but there aren't any for UTF-32 conversions. I don't have time to add a full test for that. Fixes: QTBUG-97122 Pick-to: 6.2 6.1 Change-Id: Ic17a33f599b844d8ab5dfffd16ab2c4cb6b0547d Reviewed-by: Ievgenii Meshcheriakov Reviewed-by: Edward Welbourne Reviewed-by: Lars Knoll --- src/corelib/text/qstringconverter.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/corelib/text/qstringconverter.cpp') diff --git a/src/corelib/text/qstringconverter.cpp b/src/corelib/text/qstringconverter.cpp index 09ac6512be..f0c7b6ce86 100644 --- a/src/corelib/text/qstringconverter.cpp +++ b/src/corelib/text/qstringconverter.cpp @@ -1027,8 +1027,7 @@ QByteArray QUtf32::convertFromUnicode(QStringView in, QStringConverter::State *s length += 4; QByteArray ba(length, Qt::Uninitialized); char *end = convertFromUnicode(ba.data(), in, state, endian); - Q_ASSERT(end - ba.constData() == length); - Q_UNUSED(end); + ba.truncate(end - ba.constData()); return ba; } -- cgit v1.2.3