aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
diff options
context:
space:
mode:
authorOlivier De Cannière <olivier.decanniere@qt.io>2024-01-05 15:03:20 +0100
committerOlivier De Cannière <olivier.decanniere@qt.io>2024-01-09 10:40:49 +0100
commit22d4a1b7950fa71566c53290a98be3397e910084 (patch)
tree67e759d5bb0f9e2cf233a5193583054fe7eb8ace /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
parent7b9f69a69e669063c082ca5b8e3e53968978f17d (diff)
Compiler: Guard against null dereference when ignoring function return
When a function is called, two arrays with the necessary information are passed to the engine: argv: [return address, prameter 1 address, parameter 2 address, ...] types: [return type, parameter 1 type, parameter 2 type, ...] When the result of the call is ignored, the return type is set to void and the return address to null. A check for this null value was missing leading to a null derefence. Amends: 4f1b9156a48e44cf1f127a4563d0ac69ab436f12 Fixes: QTBUG-120336 Pick-to: 6.7 Change-Id: I4a21779f3276b0143087b41b0d16c0cd3ba0e7db Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
-rw-r--r--tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index a0416ac159..90114f8f5a 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -111,6 +111,7 @@ private slots:
void getOptionalLookup_data();
void globals();
void idAccess();
+ void ignoredFunctionReturn();
void importsFromImportPath();
void inPlaceDecrement();
void inaccessibleProperty();
@@ -2142,6 +2143,15 @@ void tst_QmlCppCodegen::idAccess()
QCOMPARE(f.pointSize(), 22);
}
+void tst_QmlCppCodegen::ignoredFunctionReturn()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, QUrl(u"qrc:/qt/qml/TestTypes/ignoredFunctionReturn.qml"_s));
+ QVERIFY2(!component.isError(), component.errorString().toUtf8());
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY(!object.isNull());
+}
+
void tst_QmlCppCodegen::importsFromImportPath()
{
QQmlEngine engine;