diff options
| author | Marc Mutz <marc.mutz@qt.io> | 2025-03-04 12:22:06 +0100 |
|---|---|---|
| committer | Marc Mutz <marc.mutz@qt.io> | 2025-03-06 21:57:22 +0000 |
| commit | 4eb9e0d3eedfc1b6de968308167af01b19f6ffe7 (patch) | |
| tree | b9f7dd9c68dd5866b0e8272331c2b4ab0a57d271 /src/corelib/text/qstring.cpp | |
| parent | a817ba8e9c42dfffd31eb26ac522488c2a4ec61e (diff) | |
ucstricmp8: fix Coverity ARRAY_VS_SINGLETON issue
Coverity has this checker where it complains if you use a T as a
T[1]. The C++ standard says this is fine¹, but qstring.cpp,
specifically, is security-critical, so we shouldn't leave Coverity
issues unfixed in there.
So replace uc1 with a decoded[1] array and make both output and uc1
point to decoded's first (and only) element.
Amends 45838673df6e64a6fd42570c4e8874c5181f7717.
¹ https://eel.is/c++draft/basic.compound#3.sentence-11
Pick-to: 6.9 6.8 6.5
Coverity-Id: 378348
Change-Id: Ib149386defd8b263df522a4f12b1af1b3fc1a20c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/text/qstring.cpp')
| -rw-r--r-- | src/corelib/text/qstring.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index c0cc5d16164..de9560f121e 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -1243,8 +1243,9 @@ Q_NEVER_INLINE static int ucstricmp8(const char *utf8, const char *utf8end, cons QStringIterator src2(utf16, utf16end); while (src1 < end1 && src2.hasNext()) { - char32_t uc1 = 0; - char32_t *output = &uc1; + char32_t decoded[1]; + char32_t *output = decoded; + char32_t &uc1 = decoded[0]; uchar b = *src1++; const qsizetype res = QUtf8Functions::fromUtf8<QUtf8BaseTraits>(b, output, src1, end1); if (res < 0) { |
