From ea74f0c68cddf706c950d3910cf7b363fe24885b Mon Sep 17 00:00:00 2001
From: Ulf Hermann <ulf.hermann@qt.io>
Date: Wed, 17 Apr 2019 12:35:42 +0200
Subject: Don't crash when accessing invalid properties through QObjectWrapper

Change-Id: I613bf5dc685bb4235262b429d8f7318ea144fb9d
Fixes: QTBUG-75203
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
---
 src/qml/jsruntime/qv4qobjectwrapper.cpp              |  2 +-
 .../data/undefinedPropertiesInObjectWrapper.qml      | 20 ++++++++++++++++++++
 tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 10 ++++++++++
 3 files changed, 31 insertions(+), 1 deletion(-)
 create mode 100644 tests/auto/qml/qqmlecmascript/data/undefinedPropertiesInObjectWrapper.qml

diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
index 377c30617..5467e730e 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
+++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
@@ -856,7 +856,7 @@ ReturnedValue QObjectWrapper::virtualResolveLookupGetter(const Object *object, E
     if (!ddata || !ddata->propertyCache) {
         QQmlPropertyData local;
         QQmlPropertyData *property = QQmlPropertyCache::property(engine->jsEngine(), qobj, name, qmlContext, local);
-        return getProperty(engine, qobj, property);
+        return property ? getProperty(engine, qobj, property) : QV4::Encode::undefined();
     }
     QQmlPropertyData *property = ddata->propertyCache->property(name.getPointer(), qobj, qmlContext);
 