Skip to content

Commit 61017a7

Browse files
rdmarsh2MathiasVP
authored andcommitted
C++: prevent a bad join order
1 parent 7f6b400 commit 61017a7

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

cpp/ql/src/experimental/Likely Bugs/ArrayAccessProductFlow.ql

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,8 @@ class ArraySizeConfiguration extends ProductFlow::Configuration {
2424
}
2525

2626
override predicate isSinkPair(DataFlow::Node sink1, DataFlow::Node sink2) {
27-
exists(PointerAddInstruction pai, Instruction index, Bound b, int delta |
28-
pai.getRight() = index and
29-
pai.getLeft() = sink1.asInstruction() and
30-
bounded(index, b, delta, true) and
31-
sink2.asInstruction() = b.getInstruction() and
27+
exists(PointerAddInstruction pai, int delta |
28+
isSinkPair1(sink1, sink2, pai, delta) and
3229
(
3330
delta = 0 and
3431
exists(DataFlow::Node paiNode, DataFlow::Node derefNode |
@@ -43,6 +40,18 @@ class ArraySizeConfiguration extends ProductFlow::Configuration {
4340
}
4441
}
4542

43+
pragma[nomagic]
44+
predicate isSinkPair1(
45+
DataFlow::Node sink1, DataFlow::Node sink2, PointerAddInstruction pai, int delta
46+
) {
47+
exists(Instruction index, ValueNumberBound b |
48+
pai.getRight() = index and
49+
pai.getLeft() = sink1.asInstruction() and
50+
bounded(index, b, delta, true) and
51+
sink2.asInstruction() = b.getInstruction()
52+
)
53+
}
54+
4655
from
4756
ArraySizeConfiguration conf, DataFlow::PathNode source1, DataFlow2::PathNode source2,
4857
DataFlow::PathNode sink1, DataFlow2::PathNode sink2

0 commit comments

Comments
 (0)