Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* Captured variables are currently considered live when the capturing function exits normally. Now they are also considered live when the capturing function exits via an exception.
1 change: 0 additions & 1 deletion ruby/ql/lib/codeql/ruby/dataflow/internal/SsaImpl.qll
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ private predicate writesCapturedVariable(Cfg::BasicBlock bb, LocalVariable v) {
* at index `i` in exit block `bb`.
*/
private predicate capturedExitRead(Cfg::AnnotatedExitBasicBlock bb, int i, LocalVariable v) {
bb.isNormal() and
writesCapturedVariable(bb.getAPredecessor*(), v) and
i = bb.length()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,34 @@ def m(y)
y = 3 # OK - the call to `super` sees the value of `y``
super
end
end

def do_twice
yield
yield
end

def get_done_twice x
do_twice do
print x
x += 1 # OK - the block is executed twice
end
end

def retry_once
yield
rescue
yield
end

def get_retried x
retry_once do
print x
if x < 1
begin
x += 1 # OK - the block may be executed again
raise StandardError
end
end
end
end
Loading