diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2021-10-05 08:33:17 -0700 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-10-11 22:07:03 +0000 |
commit | 5c5f6b453d35f2d10e1448ba5302fe1c705f2c35 (patch) | |
tree | 103684a8f520b445f37779a58c3b66d12cd76fa5 /src | |
parent | 12efdab6c70b24538d2ce4f679e74c42e98a9947 (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
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>
(cherry picked from commit 333b40a12e82edb44ee472d7b95e533a99bb32d0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/text/qstringconverter.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/corelib/text/qstringconverter.cpp b/src/corelib/text/qstringconverter.cpp index df9efe7f67..c162ba4e8a 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; } |