aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2022-12-12 12:19:36 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2022-12-12 15:33:18 +0100
commitaa4a1e96b8cdc5e6a5ea8e5e1c0406e9f496b92b (patch)
treed4c4af105dae60cfb04bbe2dd53bfb05dc3fc400 /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
parentb36864061fb36f2bf8cc30ac0b601f3b3e146c26 (diff)
QQmlJSCodeGenerator: fix nullptr dereference
If we try to lookup the length of a generic QVariant, we fail, and so far crashed. We should ideally detect that we are dealing with an array (and thus length is a known, available property), but for now simply reject compilation to C++. Pick-to: 6.4 Fixes: QTBUG-109164 Change-Id: I9d4149ac09a351754d012dbc829774413d6b32eb Reviewed-by: Semih Yavuz <semih.yavuz@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
-rw-r--r--tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index 2cbf2bc747..a275fff918 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -154,6 +154,7 @@ private slots:
void enumConversion();
void ambiguousSignals();
void fileImportsContainCxxTypes();
+ void lengthAccessArraySequenceCompat();
};
void tst_QmlCppCodegen::initTestCase()
@@ -2944,6 +2945,16 @@ void tst_QmlCppCodegen::fileImportsContainCxxTypes()
QCOMPARE(o->objectName(), u"horst guenther"_s);
}
+void tst_QmlCppCodegen::lengthAccessArraySequenceCompat()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, QUrl(u"qrc:/qt/qml/TestTypes/ArraySequenceLengthInterop.qml"_s));
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+ QScopedPointer<QObject> o(c.create());
+ QVERIFY(!o.isNull());
+ QCOMPARE(o->property("length").toInt(), 100);
+}
+
QTEST_MAIN(tst_QmlCppCodegen)
#include "tst_qmlcppcodegen.moc"