aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/jsruntime/qv4object.cpp3
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp14
2 files changed, 16 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp
index 2f664c6398..12157af728 100644
--- a/src/qml/jsruntime/qv4object.cpp
+++ b/src/qml/jsruntime/qv4object.cpp
@@ -61,7 +61,8 @@ DEFINE_OBJECT_VTABLE(Object);
void Object::setInternalClass(InternalClass *ic)
{
d()->internalClass = ic;
- if ((!d()->memberData && ic->size) || (d()->memberData->size < ic->size))
+ bool hasMD = d()->memberData != nullptr;
+ if ((!hasMD && ic->size) || (hasMD && d()->memberData->size < ic->size))
d()->memberData = MemberData::allocate(ic->engine, ic->size, d()->memberData);
}
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 89dac33671..83725dbf12 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -333,6 +333,7 @@ private slots:
void stringify_qtbug_50592();
void instanceof_data();
void instanceof();
+ void freeze_empty_object();
private:
// static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter);
@@ -8183,6 +8184,19 @@ void tst_qqmlecmascript::instanceof()
}
}
+void tst_qqmlecmascript::freeze_empty_object()
+{
+ // this shouldn't crash
+ QJSEngine engine;
+ QJSValue v = engine.evaluate(QString::fromLatin1(
+ "var obj = {};\n"
+ "Object.freeze(obj);\n"
+ ));
+ QVERIFY(!v.isError());
+ QCOMPARE(v.toBool(), true);
+}
+
+
QTEST_MAIN(tst_qqmlecmascript)
#include "tst_qqmlecmascript.moc"