From dcbc8f16d0c1b6e394a1f6900310065c38895a4c Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 4 Nov 2020 15:01:30 +0100 Subject: [PATCH] Be explicit in a uint->QChar conversion And check that the result fits. Change-Id: Iaee1085315559bdffea9400b94b29869621ab7ff Reviewed-by: Edward Welbourne Reviewed-by: Thiago Macieira --- src/corelib/text/qstringconverter.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/corelib/text/qstringconverter.cpp b/src/corelib/text/qstringconverter.cpp index e66f512ed8c..a0015c2c837 100644 --- a/src/corelib/text/qstringconverter.cpp +++ b/src/corelib/text/qstringconverter.cpp @@ -1063,7 +1063,9 @@ char *QUtf32::convertFromUnicode(char *out, QStringView in, QStringConverter::St QChar ch; uint ucs4; if (state->remainingChars == 1) { - ch = state->state_data[Data]; + auto character = state->state_data[Data]; + Q_ASSERT(character <= 0xFFFF); + ch = QChar(character); // this is ugly, but shortcuts a whole lot of logic that would otherwise be required state->remainingChars = 0; goto decode_surrogate;