summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qstringconverter.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2021-10-05 08:33:17 -0700
committerThiago Macieira <thiago.macieira@intel.com>2021-10-11 11:08:15 -0700
commit333b40a12e82edb44ee472d7b95e533a99bb32d0 (patch)
treeb961872fa2b64ae5dd14de63832c9a8d7c2d2ffb /src/corelib/text/qstringconverter.cpp
parent2b77e779ce43386d14bdd2d1109ee182bcd0d047 (diff)
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 <ievgenii.meshcheriakov@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/text/qstringconverter.cpp')
-rw-r--r--src/corelib/text/qstringconverter.cpp3
1 files changed, 1 insertions, 2 deletions
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;
}