Fix crash when running some QML auto-tests
authorSimon Hausmann <simon.hausmann@digia.com>
Sun, 12 May 2013 13:00:48 +0000 (15:00 +0200)
committerLars Knoll <lars.knoll@digia.com>
Mon, 13 May 2013 07:52:33 +0000 (09:52 +0200)
Engine identifiers are strings, which as Managed sub-classes have a pointer to
the internalClass. For strings we generally use engine->emptyClass. So before
creating any identifiers, engine->emptyClass must be initialized. Otherwise
putting any of the identifiers later into for example a QV4::PersistentValue
will cause crashes, because string->internalClass->engine will be an
uninitialized value.

Change-Id: I35a19a1701c5938b61f61e876d656e126a9b8e09
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/qml/qml/v4/qv4engine.cpp

index c7a6beb..98d661a 100644 (file)
@@ -95,6 +95,8 @@ ExecutionEngine::ExecutionEngine(QQmlJS::EvalISelFactory *factory)
 
     identifierCache = new Identifiers(this);
 
+    emptyClass =  new (classPool.allocate(sizeof(InternalClass))) InternalClass(this);
+
     id_undefined = newIdentifier(QStringLiteral("undefined"));
     id_null = newIdentifier(QStringLiteral("null"));
     id_true = newIdentifier(QStringLiteral("true"));
@@ -121,7 +123,6 @@ ExecutionEngine::ExecutionEngine(QQmlJS::EvalISelFactory *factory)
     id_uintMax = newIdentifier(QStringLiteral("4294967295"));
     id_name = newIdentifier(QStringLiteral("name"));
 
-    emptyClass =  new (classPool.allocate(sizeof(InternalClass))) InternalClass(this);
     arrayClass = emptyClass->addMember(id_length, Attr_NotConfigurable|Attr_NotEnumerable);
     initRootContext();