mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Merge pull request #19483 from yoff/ruby/more-capturedExitRead
Ruby: More captured exit read nodes
This commit is contained in:
@@ -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.
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -33,4 +33,34 @@ class Sub < Sup
|
||||
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
|
||||
Reference in New Issue
Block a user