C28106

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at C28106.

Warning C28106: Variable already holds resource possibly causing leak

A variable that contains a resource is used in a context in which a new value can be placed in the variable. If this occurs, the resource can be lost and not properly freed, causing a resource leak.

The following code example generates this warning:

ExAcquireResourceLite(resource, true);  
...  
ExAcquireResourceLite(resource, true);  

The following code example avoids this warning:

ExAcquireResourceLite(resource1, true);  
...  
ExAcquireResourceLite(resource2, true);  

Show: