From: Alan Alpert <416365416c@gmail.com> Date: Mon, 17 Dec 2012 01:35:12 +0000 (-0800) Subject: Move VME exception to a better place X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=6163ae74d505a3e9733795c6ce63386038f826d1;p=konrad%2Fqtdeclarative.git Move VME exception to a better place 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 --- diff --git a/src/qml/qml/qqmlvme.cpp b/src/qml/qml/qqmlvme.cpp index 9db3ee5..00d8ad8 100644 --- a/src/qml/qml/qqmlvme.cpp +++ b/src/qml/qml/qqmlvme.cpp @@ -558,6 +558,11 @@ QObject *QQmlVME::run(QList *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 *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;