Skip to content

Commit d3d706d

Browse files
committed
C++: Fix accidental cartesian product.
1 parent 0d6fdc6 commit d3d706d

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

cpp/ql/lib/experimental/semmle/code/cpp/dataflow/ProductFlow.qll

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ module ProductFlow {
368368
TJump()
369369

370370
private predicate into1(Flow1::PathNode pred1, Flow1::PathNode succ1, TKind kind) {
371+
Flow1::PathGraph::edges(pred1, succ1) and
371372
exists(DataFlowCall call |
372373
kind = TInto(call) and
373374
pred1.getNode().(ArgumentNode).getCall() = call and
@@ -376,26 +377,29 @@ module ProductFlow {
376377
}
377378

378379
private predicate out1(Flow1::PathNode pred1, Flow1::PathNode succ1, TKind kind) {
380+
Flow1::PathGraph::edges(pred1, succ1) and
379381
exists(ReturnKindExt returnKind, DataFlowCall call |
380382
kind = TOutOf(call) and
381383
succ1.getNode() = returnKind.getAnOutNode(call) and
382384
pred1.getNode().(ReturnNodeExt).getKind() = returnKind
383385
)
384386
}
385387

386-
private predicate into2(Flow2::PathNode pred1, Flow2::PathNode succ1, TKind kind) {
388+
private predicate into2(Flow2::PathNode pred2, Flow2::PathNode succ2, TKind kind) {
389+
Flow2::PathGraph::edges(pred2, succ2) and
387390
exists(DataFlowCall call |
388391
kind = TInto(call) and
389-
pred1.getNode().(ArgumentNode).getCall() = call and
390-
succ1.getNode() instanceof ParameterNode
392+
pred2.getNode().(ArgumentNode).getCall() = call and
393+
succ2.getNode() instanceof ParameterNode
391394
)
392395
}
393396

394-
private predicate out2(Flow2::PathNode pred1, Flow2::PathNode succ1, TKind kind) {
397+
private predicate out2(Flow2::PathNode pred2, Flow2::PathNode succ2, TKind kind) {
398+
Flow2::PathGraph::edges(pred2, succ2) and
395399
exists(ReturnKindExt returnKind, DataFlowCall call |
396400
kind = TOutOf(call) and
397-
succ1.getNode() = returnKind.getAnOutNode(call) and
398-
pred1.getNode().(ReturnNodeExt).getKind() = returnKind
401+
succ2.getNode() = returnKind.getAnOutNode(call) and
402+
pred2.getNode().(ReturnNodeExt).getKind() = returnKind
399403
)
400404
}
401405

0 commit comments

Comments
 (0)