aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4jsonobject.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@theqtcompany.com>2015-04-28 18:31:14 +0200
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-06-15 18:27:25 +0000
commitff3d02b108d0e91e40c3d1b05290838bf622357a (patch)
tree94f7f595ad40869b93d293b3155efda28b479ebb /src/qml/jsruntime/qv4jsonobject.cpp
parent3ef875b2aa7e850971e6865136029d450aa9928b (diff)
Fix the GC unsafe stack variable in Stringify
Change-Id: Icf90f43bedebe05a148499cd2de6726eaa993293 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/qml/jsruntime/qv4jsonobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4jsonobject.cpp17
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;