Skip to content

Commit 64c6ab4

Browse files
committed
upd cherry0pick
1 parent f59d15c commit 64c6ab4

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowPrivate.qll

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1658,6 +1658,19 @@ private module ReturnNodes {
16581658
result = n
16591659
}
16601660

1661+
private Expr getLast(StmtSequence s) {
1662+
result = getLast(s.(BodyStmt).getElse())
1663+
or
1664+
result = getLast(s.(BodyStmt).getARescue().getBody())
1665+
or
1666+
not exists(s.(BodyStmt).getElse()) and
1667+
exists(Stmt last | last = s.getLastStmt() |
1668+
result = getLast(last)
1669+
or
1670+
result = last and not last instanceof StmtSequence
1671+
)
1672+
}
1673+
16611674
/**
16621675
* A data-flow node that represents an expression implicitly returned by
16631676
* a callable. An implicit return happens when an expression can be the
@@ -1666,7 +1679,7 @@ private module ReturnNodes {
16661679
class ExprReturnNode extends SourceReturnNode, ExprNode {
16671680
ExprReturnNode() {
16681681
// exists(Callable c | implicitReturn(c, this) = c.getBody().getAStmt())
1669-
this.getExprNode().getExpr() = desugar(any(Callable c).getBody().getLastStmt())
1682+
this.getExprNode().getExpr() = desugar(getLast(any(Callable c).getBody()))
16701683
}
16711684

16721685
override ReturnKind getKindSource() {

0 commit comments

Comments
 (0)