Skip to content

Commit 5d01cb7

Browse files
committed
Python: Fix bad QL-rewriting
Original code: exists(Expr e, For forloop | forloop = loop and e.pointsTo(_, _, capturing) | not loop.contains(e) ) The new version will preserve the same semantics. The problem with the first rewrite was that `not loop.(For).somethingMore` would hold for any AstNode that was not a For
1 parent 9b0b0c3 commit 5d01cb7

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

python/ql/src/Variables/LoopVariableCapture.ql

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ predicate escaping_capturing_looping_construct(CallableExpr capturing, AstNode l
3333
capturing_looping_construct(capturing, loop, var) and
3434
// Escapes if used out side of for loop or is a lambda in a comprehension
3535
(
36-
exists(Expr e | e.pointsTo(_, _, capturing) |
37-
not loop.(For).contains(e)
38-
)
36+
loop instanceof For and
37+
exists(Expr e | e.pointsTo(_, _, capturing) | not loop.contains(e))
3938
or
4039
loop.(Comp).getElt() = capturing
4140
or

0 commit comments

Comments
 (0)