mirror of
https://github.com/github/codeql.git
synced 2026-05-05 05:35:13 +02:00
C#: Make cs/dereferenced-value-may-be-null a path query
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* @name Dereferenced variable may be null
|
||||
* @description Dereferencing a variable whose value may be 'null' may cause a
|
||||
* 'NullReferenceException'.
|
||||
* @kind problem
|
||||
* @kind path-problem
|
||||
* @problem.severity warning
|
||||
* @precision high
|
||||
* @id cs/dereferenced-value-may-be-null
|
||||
@@ -14,7 +14,8 @@
|
||||
|
||||
import csharp
|
||||
import semmle.code.csharp.dataflow.Nullness
|
||||
import PathGraph
|
||||
|
||||
from Dereference d, Ssa::SourceVariable v, string msg, Element reason
|
||||
where d.isFirstMaybeNull(v.getAnSsaDefinition(), msg, reason)
|
||||
select d, "Variable $@ may be null here " + msg + ".", v, v.toString(), reason, "this"
|
||||
from Dereference d, PathNode source, PathNode sink, Ssa::SourceVariable v, string msg, Element reason
|
||||
where d.isFirstMaybeNull(v.getAnSsaDefinition(), source, sink, msg, reason)
|
||||
select d, source, sink, "Variable $@ may be null here " + msg + ".", v, v.toString(), reason, "this"
|
||||
|
||||
Reference in New Issue
Block a user