Skip to content

Commit 06313b9

Browse files
authored
Merge pull request #15998 from MathiasVP/simplify-guard-in-incorrectly-check-scanf
C++: Simplify use of guard conditions in `cpp/incorrectly-checked-scanf`
2 parents 6619be3 + f31bb13 commit 06313b9

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

cpp/ql/src/Critical/ScanfChecks.qll

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ private import semmle.code.cpp.commons.Scanf
33
private import semmle.code.cpp.controlflow.IRGuards
44
private import semmle.code.cpp.ir.ValueNumbering
55

6-
private ConstantInstruction getZeroInstruction() { result.getValue() = "0" }
7-
8-
private Operand zero() { result.getDef() = getZeroInstruction() }
9-
106
private predicate exprInBooleanContext(Expr e) {
117
exists(IRGuardCondition gc |
128
exists(Instruction i |
@@ -46,7 +42,7 @@ private predicate checkedForEof(ScanfFunctionCall call) {
4642
gc.comparesEq(valueNumber(i).getAUse(), getEofValue().toInt(), _, _)
4743
or
4844
// call < 0 (EOF is guaranteed to be negative)
49-
gc.comparesLt(valueNumber(i).getAUse(), zero(), 0, true, _)
45+
gc.comparesLt(valueNumber(i).getAUse(), 0, true, _)
5046
)
5147
)
5248
}

0 commit comments

Comments
 (0)