Move VME exception to a better place
authorAlan Alpert <416365416c@gmail.com>
Mon, 17 Dec 2012 01:35:12 +0000 (17:35 -0800)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Tue, 8 Jan 2013 16:18:41 +0000 (17:18 +0100)
If o is not created, then ddata on the next line may also not create
successfuly leading to an invalid memory access before we reach the !o
exception.

Change-Id: I9b127dff7955456aacb25138fabaabaabaab921f
Reviewed-by: Christopher Adams <chris.adams@jollamobile.com>

src/qml/qml/qqmlvme.cpp

index 9db3ee5..00d8ad8 100644 (file)
@@ -558,6 +558,11 @@ QObject *QQmlVME::run(QList<QQmlError> *errors,
             QObject *o = 0;
             void *memory = 0;
             type.type->create(&o, &memory, sizeof(QQmlData));
+
+            if (!o)
+                VME_EXCEPTION(tr("Unable to create object of type %1").arg(type.type->elementName()),
+                              instr.line);
+
             QQmlData *ddata = new (memory) QQmlData;
             ddata->ownMemory = false;
             QObjectPrivate::get(o)->declarativeData = ddata;
@@ -572,10 +577,6 @@ QObject *QQmlVME::run(QList<QQmlError> *errors,
                 ddata->propertyCache->addref();
             }
 
-            if (!o) 
-                VME_EXCEPTION(tr("Unable to create object of type %1").arg(type.type->elementName()),
-                              instr.line);
-
             if (states.count() == 1) {
                 // Keep a reference to the compiled data we rely on
                 ddata->compiledData = states[0].compiledData;