mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +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`.
|
* at index `i` in exit block `bb`.
|
||||||
*/
|
*/
|
||||||
private predicate capturedExitRead(Cfg::AnnotatedExitBasicBlock bb, int i, LocalVariable v) {
|
private predicate capturedExitRead(Cfg::AnnotatedExitBasicBlock bb, int i, LocalVariable v) {
|
||||||
bb.isNormal() and
|
|
||||||
writesCapturedVariable(bb.getAPredecessor*(), v) and
|
writesCapturedVariable(bb.getAPredecessor*(), v) and
|
||||||
i = bb.length()
|
i = bb.length()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,3 +34,33 @@ class Sub < Sup
|
|||||||
super
|
super
|
||||||
end
|
end
|
||||||
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