Query module DisposeNotCalledOnException

name
Dispose may not be called if an exception is thrown during execution
description
Methods that create objects of type ‘IDisposable’ should call ‘Dispose()’ on those objects, even during exceptional circumstances, otherwise unmanaged resources may not be released.
kind
problem
problem.severity
warning
precision
medium
id
cs/dispose-not-called-on-throw
tags
efficiency maintainability security external/cwe/cwe-404 external/cwe/cwe-459 external/cwe/cwe-460

Imports

Dispose
System

Provides definitions related to the namespace System.

csharp

The default C# QL library.

Predicates

disposeReachableFromDisposableCreation

Holds if disposeCall disposes the object created by disposableCreation.

getAThrownException

Gets an exception type that may be thrown during the execution of method m. Assumes any exception may be thrown by library types.

isTriedAgainstException

Holds if control flow element is tried against throwing an exception of type ec.