diff options
author | Lars Knoll <[email protected]> | 2015-04-28 18:31:14 +0200 |
---|---|---|
committer | Simon Hausmann <[email protected]> | 2015-06-15 18:27:25 +0000 |
commit | ff3d02b108d0e91e40c3d1b05290838bf622357a (patch) | |
tree | 94f7f595ad40869b93d293b3155efda28b479ebb /src/qml/jsruntime/qv4jsonobject.cpp | |
parent | 3ef875b2aa7e850971e6865136029d450aa9928b (diff) |
Fix the GC unsafe stack variable in Stringify
Change-Id: Icf90f43bedebe05a148499cd2de6726eaa993293
Reviewed-by: Simon Hausmann <[email protected]>
Diffstat (limited to 'src/qml/jsruntime/qv4jsonobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4jsonobject.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp index 9cc0ccdb04..87de6a6aba 100644 --- a/src/qml/jsruntime/qv4jsonobject.cpp +++ b/src/qml/jsruntime/qv4jsonobject.cpp @@ -618,9 +618,14 @@ struct Stringify int propertyListSize; QString gap; QString indent; + QStack<Object *> stack; - // ### GC - QStack<Heap::Object *> stack; + bool stackContains(Object *o) { + for (int i = 0; i < stack.size(); ++i) + if (stack.at(i)->d() == o->d()) + return true; + return false; + } Stringify(ExecutionEngine *e) : v4(e), replacerFunction(0), propertyList(0), propertyListSize(0) {} @@ -750,7 +755,7 @@ QString Stringify::makeMember(const QString &key, const Value &v) QString Stringify::JO(Object *o) { - if (stack.contains(o->d())) { + if (stackContains(o)) { v4->throwTypeError(); return QString(); } @@ -758,7 +763,7 @@ QString Stringify::JO(Object *o) Scope scope(v4); QString result; - stack.push(o->d()); + stack.push(o); QString stepback = indent; indent += gap; @@ -809,7 +814,7 @@ QString Stringify::JO(Object *o) QString Stringify::JA(ArrayObject *a) { - if (stack.contains(a->d())) { + if (stackContains(a)) { v4->throwTypeError(); return QString(); } @@ -817,7 +822,7 @@ QString Stringify::JA(ArrayObject *a) Scope scope(a->engine()); QString result; - stack.push(a->d()); + stack.push(a); QString stepback = indent; indent += gap; |