Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4a21123

Browse files
author
Dave Bartolomeo
authored
Merge pull request #2427 from jbj/comparison-with-wider-type-notc
C++: Stricter loop-variant check
2 parents 9b5437c + 5ee19c5 commit 4a21123

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

cpp/ql/src/Security/CWE/CWE-190/ComparisonWithWiderType.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Element friendlyLoc(Expr e) {
4444
not e instanceof Access and not e instanceof Call and result = e
4545
}
4646

47-
from Loop l, RelationalOperation rel, Expr small, Expr large
47+
from Loop l, RelationalOperation rel, VariableAccess small, Expr large
4848
where
4949
small = rel.getLesserOperand() and
5050
large = rel.getGreaterOperand() and
@@ -60,7 +60,7 @@ where
6060
not getComparisonSize(large.(SubExpr).getLeftOperand().getExplicitlyConverted()) <= getComparisonSize(small) and
6161
not getComparisonSize(large.(RShiftExpr).getLeftOperand().getExplicitlyConverted()) <= getComparisonSize(small) and
6262
// ignore loop-invariant smaller variables
63-
loopVariant(small.getAChild*(), l)
63+
loopVariant(small, l)
6464
select rel,
6565
"Comparison between $@ of type " + small.getType().getName() + " and $@ of wider type " +
6666
large.getType().getName() + ".", friendlyLoc(small), small.toString(), friendlyLoc(large),

0 commit comments

Comments
 (0)