aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4functionobject.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-09-20 15:13:14 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-22 15:29:00 +0200
commit1fb3cd12c8cdc76d1986736fbd60b5810cc17045 (patch)
tree700e7e2d29231a57c945e53fe71e2ab2250e8f2a /src/qml/jsruntime/qv4functionobject.cpp
parent47bf40dd49f90b52cc1b545b2be3035d48d6199e (diff)
Fix cases where mark() would access uninitialized memory
Change-Id: I4e07e20d30ba57759a0ece1c298a02b098718b33 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4functionobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp
index a7332d65da..6c60a9964a 100644
--- a/src/qml/jsruntime/qv4functionobject.cpp
+++ b/src/qml/jsruntime/qv4functionobject.cpp
@@ -92,6 +92,9 @@ FunctionObject::FunctionObject(ExecutionContext *scope, const QString &name, boo
, varCount(0)
, function(0)
{
+ // set the name to something here, so that a gc run a few lines below doesn't crash on it
+ this->name = scope->engine->id_undefined;
+
Scope s(scope);
ScopedValue protectThis(s, this);
ScopedString n(s, s.engine->newString(name));
@@ -108,7 +111,7 @@ FunctionObject::FunctionObject(InternalClass *ic)
, function(0)
{
vtbl = &static_vtbl;
- name = (QV4::String *)0;
+ name = engine()->id_undefined;
type = Type_FunctionObject;
needsActivation = false;
@@ -125,6 +128,7 @@ FunctionObject::~FunctionObject()
void FunctionObject::init(const StringRef n, bool createProto)
{
vtbl = &static_vtbl;
+ name = n;
Scope s(engine());
ScopedValue protectThis(s, this);
@@ -143,13 +147,8 @@ void FunctionObject::init(const StringRef n, bool createProto)
memberData[Index_Prototype].value = proto.asValue();
}
- if (n) {
- name = n;
- ScopedValue v(s, n.asReturnedValue());
- defineReadonlyProperty(scope->engine->id_name, v);
- } else {
- name = (QV4::String *)0;
- }
+ ScopedValue v(s, n.asReturnedValue());
+ defineReadonlyProperty(scope->engine->id_name, v);
}
ReturnedValue FunctionObject::newInstance()