aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/v4misc/tst_v4misc.cpp
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@qt.io>2018-10-11 13:33:08 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2018-11-29 08:43:19 +0000
commit597ce09c7a1d8b89e9473faae900321ef2d4181d (patch)
tree0a64a17098ad83d5b83ccae836b1d5bbe26d8079 /tests/auto/qml/v4misc/tst_v4misc.cpp
parente7d19a2a0fcbec38b7e132634d0ebe79b772c61b (diff)
JS: Limit expression and statement nesting level
This is to prevent extremely deeply nested expressions and statements make the code-generator run out of (native) stack space. Task-number: QTBUG-71087 Change-Id: I8e1a20a361bff3e49101e535754546475a63ca18 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests/auto/qml/v4misc/tst_v4misc.cpp')
-rw-r--r--tests/auto/qml/v4misc/tst_v4misc.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/qml/v4misc/tst_v4misc.cpp b/tests/auto/qml/v4misc/tst_v4misc.cpp
index ecc3a4100c..71f0a42907 100644
--- a/tests/auto/qml/v4misc/tst_v4misc.cpp
+++ b/tests/auto/qml/v4misc/tst_v4misc.cpp
@@ -43,6 +43,8 @@ private slots:
void subClassing_data();
void subClassing();
+
+ void nestingDepth();
};
void tst_v4misc::tdzOptimizations_data()
@@ -173,6 +175,28 @@ void tst_v4misc::subClassing()
QVERIFY(!result.isError());
}
+void tst_v4misc::nestingDepth()
+{
+ { // left recursive
+ QString s(40000, '`');
+
+ QJSEngine engine;
+ QJSValue result = engine.evaluate(s);
+ QVERIFY(result.isError());
+ QCOMPARE(result.toString(), "SyntaxError: Maximum statement or expression depth exceeded");
+ }
+
+ { // right recursive
+ QString s(200000, '-');
+ s += "\nd";
+
+ QJSEngine engine;
+ QJSValue result = engine.evaluate(s);
+ QVERIFY(result.isError());
+ QCOMPARE(result.toString(), "SyntaxError: Maximum statement or expression depth exceeded");
+ }
+}
+
QTEST_MAIN(tst_v4misc);
#include "tst_v4misc.moc"