mirror of
https://github.com/github/codeql.git
synced 2026-05-03 04:39:29 +02:00
C#: Fix false positives in cs/dereferenced-value-may-be-null
This commit is contained in:
@@ -578,8 +578,12 @@ module Internal {
|
||||
*/
|
||||
Expr getNullEquivParent(Expr e) {
|
||||
result = any(QualifiableExpr qe |
|
||||
qe.getQualifier() = e and
|
||||
qe.isConditional() and
|
||||
(
|
||||
e = qe.getQualifier()
|
||||
or
|
||||
e = qe.(ExtensionMethodCall).getArgument(0)
|
||||
) and
|
||||
(
|
||||
// The accessed declaration must have a value type in order
|
||||
// for `only if` to hold
|
||||
|
||||
@@ -155,6 +155,9 @@ private predicate defMaybeNull(Ssa::Definition def, string msg, Element reason)
|
||||
reason = de.getANullCheck(_, true) and
|
||||
msg = "as suggested by $@ null check" and
|
||||
not def instanceof Ssa::PseudoDefinition and
|
||||
strictcount(Location l |
|
||||
l = any(Ssa::Definition def0 | de = def0.getARead()).getLocation()
|
||||
) = 1 and
|
||||
not nonNullDef(def) and
|
||||
// Don't use a check as reason if there is a `null` assignment
|
||||
not def.(Ssa::ExplicitDefinition).getADefinition().getSource() instanceof MaybeNullExpr
|
||||
|
||||
Reference in New Issue
Block a user