Skip to content

Commit d539ce0

Browse files
committed
C++: Use GVN for base case.
1 parent 575fbd2 commit d539ce0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

cpp/ql/src/Security/CWE/CWE-191/UnsignedDifferenceExpressionComparedZero.ql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ predicate isGuarded(SubExpr sub, Expr left, Expr right) {
4040
*/
4141
Expr exprIsLeftOrLessBase(SubExpr sub) {
4242
interestingSubExpr(sub, _) and // Manual magic
43-
result = sub.getLeftOperand()
43+
exists(Expr e | globalValueNumber(e).getAnExpr() = sub.getLeftOperand() |
44+
// result = sub.getLeftOperand() so result <= sub.getLeftOperand()
45+
result = e
46+
)
4447
}
4548

4649
/**

0 commit comments

Comments
 (0)