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

Skip to content

Commit e1fb1d2

Browse files
committed
Python: Fix logic in pruning for tests like 'x != 0' as that does not imply that 'x is None' is false.
1 parent f975b8b commit e1fb1d2

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

python/ql/src/semmle/python/Pruning.qll

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ module Pruner {
181181
abstract Constraint invert();
182182

183183
/** Holds if this constraint constrains the "truthiness" of the variable.
184-
* That is, for a variable `var` constrainted by this constraint
184+
* That is, for a variable `var` constrained by this constraint
185185
* `bool(var) is value`
186186
*/
187187
abstract predicate constrainsVariableToBe(boolean value);
@@ -341,8 +341,6 @@ module Pruner {
341341
value = true and (
342342
this.getOp() = eq() and this.intValue() != 0
343343
or
344-
this.getOp() = ne() and this.intValue() = 0
345-
or
346344
this.getOp() = lt() and this.intValue() <= 0
347345
or
348346
this.getOp() = le() and this.intValue() < 0
@@ -355,7 +353,7 @@ module Pruner {
355353

356354
override predicate impliesFalse(Constraint other) {
357355
exists(boolean b |
358-
this.constrainsVariableToBe(b) and other = TTruthy(b.booleanNot())
356+
this.constrainsVariableToBe(b) and other.constrainsVariableToBe(b.booleanNot())
359357
)
360358
or
361359
this.getOp() = eq() and other = TIsNone(true)

0 commit comments

Comments
 (0)