V611. The memory allocation and deallocation methods are incompatible.


The analyzer has detected a potential error: memory is allocated and released through incompatible methods. For example, the analyzer will warn you if memory is allocated through the 'new' operator and released through the 'free' function.

Consider an example of incorrect code:

int *p = (int *)malloc(sizeof(int) * N);
...
...
delete [] p;

This is the fixed code:

int *p = (int *)malloc(sizeof(int) * N);
...
...
free(p);

According to Common Weakness Enumeration, potential errors found by using this diagnostic are classified as CWE-590, CWE-762.

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


Do you make errors in the code?

Check your code
with PVS-Studio

Static code analysis
for C, C++, and C#

goto PVS-Studio;