V1005. The resource was acquired using 'X' function but was released using incompatible 'Y' function.

The analyzer has detected a possible error that has to do with using incompatible functions to acquire and release a resource.

For example, this warning will be issued when a file is opened using the 'fopen_s' function and closed using the 'CloseHandle' function.

Consider the following example.

FILE* file = nullptr;
errno_t err = fopen_s(&file, "file.txt", "r");

The result of executing this code is unknown. The 'CloseHandle' function may return the error status and merely cause a resource leak (fail to close the file), but more severe implications are also possible. Incorrect calls of some functions lead to undefined behavior, which means unpredictable results, including a crash.

This is what the fixed code should look like:

FILE* file = nullptr;
errno_t err = fopen_s(&file, "file.txt", "r");

This diagnostic is classified as:

You can look at examples of errors detected by the V1005 diagnostic.

Bugs Found

Checked Projects
Collected Errors
14 526
This website uses cookies and other technology to provide you a more personalized experience. By continuing the view of our web-pages you accept the terms of using these files. If you don't want your personal data to be processed, please, leave this site. Learn More →