diff options
author | Erik Verbruggen <erik.verbruggen@qt.io> | 2018-10-11 12:25:09 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2018-10-15 10:50:50 +0000 |
commit | 1a1e5789c754838473cbb81665667a4d3a42e33b (patch) | |
tree | 51987d628da11e3ccda07c1231115065c8320d1a /src/qml/compiler | |
parent | 67fbdadb3ba1aa9f86ae2d6ca3bff69479fb12be (diff) |
JS: Check lhs of an 'in' expression to be an lvalue
For example: 'for (foo() in something) {}' is not valid: a call
expression is not an lvalue.
Task-number: QTBUG-71086
Change-Id: Ia1498cd38526b073afb8e4524ceaea14dca3d65f
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/compiler')
-rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index 0776165d2a..8ff8ab7993 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -3307,6 +3307,10 @@ bool Codegen::visit(ForEachStatement *ast) Reference lhs = expression(e); if (hasError) goto error; + if (!lhs.isLValue()) { + throwReferenceError(e->firstSourceLocation(), QStringLiteral("Invalid left-hand side expression for 'in' expression")); + goto error; + } lhs = lhs.asLValue(); lhsValue.loadInAccumulator(); lhs.storeConsumeAccumulator(); |