Skip to content

Commit 72f1fe5

Browse files
committed
C#: Exclude nullness sources that are deemed non-null.
1 parent 0df0816 commit 72f1fe5

File tree

1 file changed

+10
-7
lines changed
  • csharp/ql/lib/semmle/code/csharp/controlflow

1 file changed

+10
-7
lines changed

csharp/ql/lib/semmle/code/csharp/controlflow/Guards.qll

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -442,13 +442,16 @@ class DereferenceableExpr extends Expr {
442442

443443
/** Holds if `guard` suggests that this expression may be `null`. */
444444
predicate guardSuggestsMaybeNull(Guards::Guard guard) {
445-
guard = this.getANullnessNullCheck(_, true)
446-
or
447-
LogicInput::additionalNullCheck(guard, _, this, true)
448-
or
449-
guard.isEquality(this, any(Expr n | nullValueImplied(n)), _)
450-
or
451-
Guards::nullGuard(guard, any(GuardValue v | exists(v.asBooleanValue())), this, true)
445+
not nonNullValueImplied(this) and
446+
(
447+
guard = this.getANullnessNullCheck(_, true)
448+
or
449+
LogicInput::additionalNullCheck(guard, _, this, true)
450+
or
451+
guard.isEquality(this, any(Expr n | nullValueImplied(n)), _)
452+
or
453+
Guards::nullGuard(guard, any(GuardValue v | exists(v.asBooleanValue())), this, true)
454+
)
452455
}
453456
}
454457

0 commit comments

Comments
 (0)