[new compiler] Fix invalid memory reads when JS closures outlive QML types
authorSimon Hausmann <simon.hausmann@digia.com>
Tue, 4 Mar 2014 15:15:26 +0000 (16:15 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Wed, 5 Mar 2014 14:01:07 +0000 (15:01 +0100)
commite4e4a7912b03499a20f25e261e1c515aab17e5a8
tree412e643b91e0445b64fe4389c51359bb17195be1
parent0d84dab38059345f51e8318d2474068e817ac007
[new compiler] Fix invalid memory reads when JS closures outlive QML types

If QQmlCompiledData gets destroyed while somebody still has refcount on the
QV4::CompiledData::CompilationUnit, then unit's _data_ would be freed already
by ~QQmlCompiledData. Given that compilationUnit->data is pointing to the same
malloc'ed address as QQmlCompiledData::qmlUnit, we can just let the
CompilationUnit always own the data.

Fixes tst_qquickloader and makes it possible to run the qquickcomponent tests.

Change-Id: Ie3f3e5335139236d7c2524a327665bda0a9cc847
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/qml/compiler/qqmltypecompiler.cpp
src/qml/compiler/qv4compileddata.cpp
src/qml/compiler/qv4compileddata_p.h
src/qml/compiler/qv4isel_p.cpp
src/qml/qml/qqmlcompileddata.cpp