diff options
author | Erik Verbruggen <erik.verbruggen@qt.io> | 2018-10-11 14:06:10 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2018-11-19 08:56:05 +0000 |
commit | 9d319e20cd76d25332d4aefcf92d6f174b910d51 (patch) | |
tree | 10bcd5a25aedc34c8a77156549ae6baddfacc790 | |
parent | 3e9b752bf4114b2b06e2f8f65aad67606dfc0215 (diff) |
JS: Handle check for dangling jump gracefully
The destructor for the Jump object will check if it is linked somewhere.
So when doing an early-exit after generating a jump (and before linking
it) and after an error occurred, make sure to call link anyway. At this
point no code will be generated, so where the jump points to is kinda
pointless.
Change-Id: I09fa03d4224805a838088acd0c5c83d02b328045
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
-rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qml/v4misc/tst_v4misc.cpp | 1 |
2 files changed, 4 insertions, 1 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index 75c47164c9..2418e0e7de 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -2077,8 +2077,10 @@ bool Codegen::visit(ConditionalExpression *ast) iffalse.link(); Reference ko = expression(ast->ko); - if (hasError) + if (hasError) { + jump_endif.link(); // dummy link, to prevent assert in Jump destructor from triggering return false; + } ko.loadInAccumulator(); jump_endif.link(); diff --git a/tests/auto/qml/v4misc/tst_v4misc.cpp b/tests/auto/qml/v4misc/tst_v4misc.cpp index c35f412870..10df673333 100644 --- a/tests/auto/qml/v4misc/tst_v4misc.cpp +++ b/tests/auto/qml/v4misc/tst_v4misc.cpp @@ -116,6 +116,7 @@ void tst_v4misc::parserMisc_data() QTest::newRow("[1]=7[A=8=9]") << QString("ReferenceError: left-hand side of assignment operator is not an lvalue"); QTest::newRow("var asmvalsLen = asmvals{{{{{ngth}}}}};") << QString("SyntaxError: Expected token `;'"); QTest::newRow("T||9[---L6i]") << QString("ReferenceError: Prefix ++ operator applied to value that is not a reference."); + QTest::newRow("a?b:[---Hi]") << QString("ReferenceError: Prefix ++ operator applied to value that is not a reference."); } void tst_v4misc::parserMisc() |