C28195

 

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 C28195.

warning C28195: The function was declared as acquiring memory in a variable and exited without doing so

This warning indicates that the function prototype for the function being analyzed has a __drv_acquiresMemory annotation. The __drv_acquiresMemory annotation indicates that the function acquires memory in the designated result location, but in at least one path, the function did not acquire the memory. Note that the Code Analysis tool will not recognize the actual implementation of a memory allocator (involving address arithmetic) and will not recognize that memory is allocated (although many wrappers will be recognized). In this case, the Code Analysis tool does not recognize that the memory was allocated and issues this warning. To suppress the false positive, use a #pragma warning on the line that precedes the opening brace { of the function body

Show: