Skip to content

Commit f2beb9e

Browse files
authored
Merge pull request github#8622 from MathiasVP/fix-cpp-performance
C++: Fix bad magic and bad join
2 parents 46c27dd + dc88f71 commit f2beb9e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

cpp/ql/lib/semmle/code/cpp/controlflow/StackVariableReachability.qll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ abstract class StackVariableReachability extends string {
8080
j > i and
8181
sink = bb.getNode(j) and
8282
this.isSink(sink, v) and
83-
not exists(int k | this.isBarrier(bb.getNode(k), v) | k in [i + 1 .. j - 1])
83+
not exists(int k, ControlFlowNode node |
84+
node = bb.getNode(k) and this.isBarrier(pragma[only_bind_into](node), v)
85+
|
86+
k in [i + 1 .. j - 1]
87+
)
8488
)
8589
or
8690
not exists(int k | this.isBarrier(bb.getNode(k), v) | k > i) and

cpp/ql/lib/semmle/code/cpp/security/Overflow.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ predicate guardedAbs(Operation e, Expr use) {
2525
* Holds if the value of `use` is guarded to be less than something, and `e`
2626
* is in code controlled by that guard (where the guard condition held).
2727
*/
28+
pragma[nomagic]
2829
predicate guardedLesser(Operation e, Expr use) {
2930
exists(GuardCondition c | c.ensuresLt(use, _, _, e.getBasicBlock(), true))
3031
or
@@ -35,6 +36,7 @@ predicate guardedLesser(Operation e, Expr use) {
3536
* Holds if the value of `use` is guarded to be greater than something, and `e`
3637
* is in code controlled by that guard (where the guard condition held).
3738
*/
39+
pragma[nomagic]
3840
predicate guardedGreater(Operation e, Expr use) {
3941
exists(GuardCondition c | c.ensuresLt(use, _, _, e.getBasicBlock(), false))
4042
or

0 commit comments

Comments
 (0)