Skip to content

Commit 3508ca8

Browse files
committed
Java: Restrict SSA reads to the reachable CFG.
1 parent b1e53f5 commit 3508ca8

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

java/ql/lib/semmle/code/java/dataflow/internal/BaseSSA.qll

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,15 @@ private module SsaInput implements SsaImplCommon::InputSig<Location> {
168168
* Holds if the `i`th of basic block `bb` reads source variable `v`.
169169
*/
170170
predicate variableRead(BasicBlock bb, int i, SourceVariable v, boolean certain) {
171-
exists(VarRead use |
172-
v.getAnAccess() = use and bb.getNode(i) = use.getControlFlowNode() and certain = true
171+
hasDominanceInformation(bb) and
172+
(
173+
exists(VarRead use |
174+
v.getAnAccess() = use and bb.getNode(i) = use.getControlFlowNode() and certain = true
175+
)
176+
or
177+
variableCapture(v, _, bb, i) and
178+
certain = false
173179
)
174-
or
175-
variableCapture(v, _, bb, i) and
176-
certain = false
177180
}
178181
}
179182

java/ql/lib/semmle/code/java/dataflow/internal/SsaImpl.qll

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,15 @@ private module SsaInput implements SsaImplCommon::InputSig<Location> {
204204
* This includes implicit reads via calls.
205205
*/
206206
predicate variableRead(BasicBlock bb, int i, SourceVariable v, boolean certain) {
207-
exists(VarRead use |
208-
v.getAnAccess() = use and bb.getNode(i) = use.getControlFlowNode() and certain = true
207+
hasDominanceInformation(bb) and
208+
(
209+
exists(VarRead use |
210+
v.getAnAccess() = use and bb.getNode(i) = use.getControlFlowNode() and certain = true
211+
)
212+
or
213+
variableCapture(v, _, bb, i) and
214+
certain = false
209215
)
210-
or
211-
variableCapture(v, _, bb, i) and
212-
certain = false
213216
}
214217
}
215218

0 commit comments

Comments
 (0)