Skip to content

Commit f2352f7

Browse files
committed
Java: Teach guards that exceptions in catch-clauses are non-null.
1 parent 0245270 commit f2352f7

File tree

1 file changed

+7
-0
lines changed
  • java/ql/lib/semmle/code/java/controlflow

1 file changed

+7
-0
lines changed

java/ql/lib/semmle/code/java/controlflow/Guards.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ private predicate isNonFallThroughPredecessor(SwitchCase sc, ControlFlowNode pre
141141

142142
private module GuardsInput implements SharedGuards::InputSig<Location> {
143143
private import java as J
144+
private import semmle.code.java.dataflow.internal.BaseSSA
144145
private import semmle.code.java.dataflow.NullGuards as NullGuards
145146
import SuccessorType
146147

@@ -216,6 +217,12 @@ private module GuardsInput implements SharedGuards::InputSig<Location> {
216217
f.isFinal() and
217218
f.getInitializer() = NullGuards::baseNotNullExpr()
218219
)
220+
or
221+
exists(CatchClause cc, LocalVariableDeclExpr decl, BaseSsaUpdate v |
222+
decl = cc.getVariable() and
223+
decl = v.getDefiningExpr() and
224+
this = v.getAUse()
225+
)
219226
}
220227
}
221228

0 commit comments

Comments
 (0)