summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2022-06-14 10:10:51 -0700
committerThiago Macieira <thiago.macieira@intel.com>2022-06-15 15:43:32 -0700
commit2a1122f46587e27f3d93e1f2af63f439116569c4 (patch)
treef962366467ebdb142085d53e9a43d349fd2a4662 /tests
parent1eb2d4d0da121b51832136773f4c863d3e9affc5 (diff)
QStringConverter: fix use-after-free in the stack in the test
Detected by ASan. Introduced by aef27c5aa2f43e8e34970168dfc517062cc87db8 Pick-to: 6.3 6.4 Fixes: QTBUG-104261 Change-Id: Id0fb9ab0089845ee8843fffd16f88bdeb4f42c7c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
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;
}
}
}