summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2022-06-14 10:10:51 -0700
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-06-16 14:38:16 +0000
commit34a130a2da2984752a84869d20b7ffb19012836b (patch)
treec87160c4c570a75fcf01473b30dd70819e408863 /tests
parent5039fec32a4a9c50912617dea639415f21b52f72 (diff)
QStringConverter: fix use-after-free in the stack in the test
Detected by ASan. Introduced by aef27c5aa2f43e8e34970168dfc517062cc87db8 Fixes: QTBUG-104261 Change-Id: Id0fb9ab0089845ee8843fffd16f88bdeb4f42c7c Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 2a1122f46587e27f3d93e1f2af63f439116569c4) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/text/qstringconverter/tst_qstringconverter.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/tests/auto/corelib/text/qstringconverter/tst_qstringconverter.cpp b/tests/auto/corelib/text/qstringconverter/tst_qstringconverter.cpp
index 231df0390e..633346a639 100644
--- a/tests/auto/corelib/text/qstringconverter/tst_qstringconverter.cpp
+++ b/tests/auto/corelib/text/qstringconverter/tst_qstringconverter.cpp
@@ -351,13 +351,17 @@ void tst_QStringConverter::roundtrip_data()
}
if (code.limitation == FullUnicode) {
- const char32_t zeroVal = 0x11136; // Unicode's representation of Chakma zero
- for (int i = 0; i < 10; ++i) {
- QChar data[] = {
- QChar::highSurrogate(zeroVal + i), QChar::lowSurrogate(zeroVal + i),
- };
- QTest::addRow("%s:Chakma-digit-%d", code.name, i) << QStringView(data) << code.code;
- }
+ using Digits = std::array<QChar, 2>;
+ using DigitsArray = std::array<Digits, 10>;
+ static constexpr DigitsArray chakmaDigits = []() {
+ const char32_t zeroVal = 0x11136; // Unicode's representation of Chakma zero
+ DigitsArray r;
+ for (int i = 0; i < int(r.size()); ++i)
+ r[i] = { QChar::highSurrogate(zeroVal + i), QChar::lowSurrogate(zeroVal + i) };
+ return r;
+ }();
+ for (int i = 0; i < int(chakmaDigits.size()); ++i)
+ QTest::addRow("%s:Chakma-digit-%d", code.name, i) << QStringView(chakmaDigits[i]) << code.code;
}
}
}