The C programming language provides several ways to allocate memory which can be used by a C++ program, such as std::malloc(), std::calloc(), and std::realloc(). However, it only defines a single way to free the allocated memory: std::free(). See MEM31-C. Free dynamically allocated memory when no longer needed and MEM34-C. Only free memory allocated dynamically for rules specifically regarding C allocation and deallocation requirements.
...
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
|---|---|---|---|---|---|
MEM31MEM51-CPP | High | Likely | Medium | P18 | L1 |
...
| CERT C++ Coding Standard | MEM53-CPP. Explicitly initiate and terminate object lifetime when performing manual lifetime management |
| CERT C Secure Coding Standard | MEM31-C. Free dynamically allocated memory when no longer needed |
| MITRE CWE | CWE 590, Free of Memory Not on the Heap CWE 415, Double Free CWE 404, Improper Resource Shutdown or Release CWE 762, Mismatched Memory Management Routines |
...