Skip to content

Commit a52c2cb

Browse files
baywetmichaelnebel
andauthored
chore: applies review suggestion
Co-authored-by: Michael Nebel <michaelnebel@github.com>
1 parent baab759 commit a52c2cb

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

csharp/ql/lib/Linq/Helpers.qll

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ private predicate returnsLoopVariable(ForeachStmt fes, Stmt s, ReturnStmt ret) {
2828
private predicate hasNullDefault(Type t) { t.isRefType() or t instanceof NullableType }
2929

3030
private predicate returnsDefaultValue(ForeachStmt fes, ReturnStmt ret) {
31-
exists(Type elementType |
32-
elementType = fes.getVariable().getType() |
31+
exists(BlockStmt enclosingBlock, int i, Type elementType |
32+
enclosingBlock.getStmt(i) = fes and
33+
enclosingBlock.getStmt(i + 1) = ret and
34+
elementType = fes.getVariable().getType()
35+
|
3336
ret.getExpr().stripCasts() instanceof NullLiteral and
3437
hasNullDefault(elementType)
3538
or

0 commit comments

Comments
 (0)