aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4qobjectwrapper.cpp
diff options
context:
space:
mode:
authorUlf Hermann <[email protected]>2023-07-05 13:12:01 +0200
committerUlf Hermann <[email protected]>2023-07-06 11:26:17 +0200
commit3110117bfaa36c5363bfa46cd82b01ff6723dd8d (patch)
tree164f6dae0fc97e37a2a4224617af4d537c498a99 /src/qml/jsruntime/qv4qobjectwrapper.cpp
parentc0849af7251d0174b083ad2dc024f79bea62a869 (diff)
QML: Check result when constructing object from metaobject
If you pass insufficient arguments to call the ctor, the resulting object is null and cannot be used. Pick-to: 6.6 6.5 6.2 Fixes: QTBUG-114910 Change-Id: Ib184684b6a7665bcdc1a3fe8f8a2401a33a8ac1c Reviewed-by: Semih Yavuz <[email protected]> Reviewed-by: Fabian Kosmale <[email protected]>
Diffstat (limited to 'src/qml/jsruntime/qv4qobjectwrapper.cpp')
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
index 38b9226c9f..14a4c67f96 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
+++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
@@ -2786,9 +2786,11 @@ ReturnedValue QMetaObjectWrapper::constructInternal(const Value *argv, int argc)
objectOrGadget, d()->constructors, d()->constructorCount, v4, callData)) {
object = CallPrecise(objectOrGadget, *ctor, v4, callData, QMetaObject::CreateInstance);
}
- Scoped<QMetaObjectWrapper> metaObject(scope, this);
- object->defineDefaultProperty(v4->id_constructor(), metaObject);
- object->setPrototypeOf(const_cast<QMetaObjectWrapper*>(this));
+ if (object) {
+ Scoped<QMetaObjectWrapper> metaObject(scope, this);
+ object->defineDefaultProperty(v4->id_constructor(), metaObject);
+ object->setPrototypeOf(const_cast<QMetaObjectWrapper*>(this));
+ }
return object.asReturnedValue();
}