C#: Fix for false positive.

This commit is contained in:
Calum Grant
2019-10-23 12:26:01 +01:00
parent ee7cf17b15
commit 01ad93d199
2 changed files with 10 additions and 2 deletions

View File

@@ -54,7 +54,16 @@ private class Conf extends DataFlow::Configuration {
)
or
// A disposing method
exists(Call c, Parameter p | e = c.getArgumentForParameter(p) | mayBeDisposed(p))
exists(Call c, Parameter p |
e = c.getArgumentForParameter(p)
or
// e.g `Stream.Create(input ?? new TextReader())`
exists(NullCoalescingExpr nce |
nce = c.getArgumentForParameter(p) and e = nce.getRightOperand()
)
|
mayBeDisposed(p)
)
or
// Things that are assigned to fields, properties, or indexers may be disposed
exists(AssignableDefinition def, Assignable a |

View File

@@ -2,5 +2,4 @@
| NoDisposeCallOnLocalIDisposable.cs:53:18:53:73 | object creation of type FileStream | Disposable 'FileStream' is created here but is not disposed. |
| NoDisposeCallOnLocalIDisposable.cs:54:9:54:64 | object creation of type FileStream | Disposable 'FileStream' is created here but is not disposed. |
| NoDisposeCallOnLocalIDisposable.cs:76:25:76:71 | call to method Create | Disposable 'XmlReader' is created here but is not disposed. |
| NoDisposeCallOnLocalIDisposable.cs:88:42:88:64 | object creation of type StringReader | Disposable 'StringReader' is created here but is not disposed. |
| NoDisposeCallOnLocalIDisposableBad.cs:8:22:8:56 | object creation of type FileStream | Disposable 'FileStream' is created here but is not disposed. |