diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-10-14 12:39:52 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-10-16 08:20:12 +0200 |
commit | d1047887a6fd4f890484203a01ee5f1eefc1a20a (patch) | |
tree | 51d7d0be382644c2a6551652adb366d20d865205 | |
parent | 03196c9a0f1635ce78cf53addb6b688108f66fae (diff) |
Make ScopedValue's CHECK_EXCEPTION also check isInterrupted
While there should be no way to generate an infinite loop from any of
the affected methods, you can certainly generate a really long loop, for
example with Array(1E9).join(). We should be able to interrupt this.
Also, the various call()s could return with isInterrupted set. We should
respect that and immediately return.
Fixes: QTBUG-78955
Change-Id: I7e18b24db0bf39df03134027b2b5dba452ac7c1c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r-- | src/qml/jsruntime/qv4scopedvalue_p.h | 2 | ||||
-rw-r--r-- | tests/auto/qml/qjsengine/tst_qjsengine.cpp | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h index e4aceef3ee..12a6381e6f 100644 --- a/src/qml/jsruntime/qv4scopedvalue_p.h +++ b/src/qml/jsruntime/qv4scopedvalue_p.h @@ -70,7 +70,7 @@ struct ScopedValue; #define CHECK_EXCEPTION() \ do { \ - if (scope.hasException()) { \ + if (scope.hasException() || scope.engine->isInterrupted.loadAcquire()) { \ return QV4::Encode::undefined(); \ } \ } while (false) diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index 1c895eb793..f1ff396d4f 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -4888,6 +4888,7 @@ void tst_QJSEngine::interrupt_data() QTest::addRow("labeled continue / %s", mode) << i << "a: while (true) { for (;;) { continue a; } }"; QTest::addRow("labeled break / %s", mode) << i << "while (true) { a: for (;;) { break a; } }"; QTest::addRow("tail call / %s", mode) << i << "'use strict';\nfunction x() { return x(); }; x();"; + QTest::addRow("huge array join / %s", mode) << i << "Array(1E9)|1"; } } |