diff options
| author | Marc Mutz <marc.mutz@qt.io> | 2025-10-16 11:03:46 +0200 |
|---|---|---|
| committer | Marc Mutz <marc.mutz@qt.io> | 2025-10-19 18:24:52 +0200 |
| commit | e2745f98b6fbd4818beb8336ebc9c69a9757bc1f (patch) | |
| tree | e7c346c78aabf1c780d05e7321169e1eb46a513d /src/corelib/text/qstring.cpp | |
| parent | bda2c016f52318a52a0a6cb9fe0e6d0f21c9ddbe (diff) | |
QChar: fix the signature of foldCase(char32_t, char32_t&)
The only caller, ucstricmp(), passes UTF-16 code units, as implied by
the implementation of foldCase(char32_t, char32_t&) (which decodes
surrogate pairs, which shouldn't exist in UTF-32, and, if they do, not
be decoded). Of course, the accumulator variables were char32_t, but
only because C++ enforces this, due to the foldCase() signature.
Fix by taking both arguments as char16_t instead of char32_t.
As a drive-by, don't store the first argument in a char32_t and then
narrow it for the QChar::*surrogate*() calls, use the argument
instead.
Found by Clang 21's -Wcharacter-conversion.
Amends the start of the public history.
Pick-to: 6.10 6.8 6.5
Change-Id: Ic08b695749d7f68353a4af8703eb6a86ba88d567
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Diffstat (limited to 'src/corelib/text/qstring.cpp')
| -rw-r--r-- | src/corelib/text/qstring.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index eea66810b0b..615cf3e6752 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -1197,8 +1197,8 @@ Q_NEVER_INLINE static int ucstricmp(qsizetype alen, const char16_t *a, qsizetype if (a == b) return qt_lencmp(alen, blen); - char32_t alast = 0; - char32_t blast = 0; + char16_t alast = 0; + char16_t blast = 0; qsizetype l = qMin(alen, blen); qsizetype i; for (i = 0; i < l; ++i) { |
