Memory Management (MEM)
- MEM50-CPP. Do not access freed memory
- MEM51-CPP. Properly deallocate dynamically allocated resources
- MEM52-CPP. Detect and handle memory allocation errors
- MEM53-CPP. Explicitly construct and destruct objects when manually managing object lifetime
- MEM54-CPP. Provide placement new with properly aligned pointers to sufficient storage capacity
- MEM55-CPP. Honor replacement dynamic storage management requirements
- MEM56-CPP. Do not store an already-owned pointer value in an unrelated smart pointer
- MEM57-CPP. Avoid using default operator new for over-aligned types
The following rules from the SEI CERT C Coding Standard also apply in C++:
- MEM30-C. Do not access freed memory
- MEM31-C. Free dynamically allocated memory when no longer needed
- MEM34-C. Only free memory allocated dynamically
- MEM35-C. Allocate sufficient memory for an object
- MEM36-C. Do not modify the alignment of objects by calling realloc()
Information for Editors
To have a new guideline automatically listed above be sure to label it mem and rule .
Risk Assessment Summary
| Rule | Severity | Likelihood | Detectable | Repairable | Priority | Level |
|---|---|---|---|---|---|---|
| MEM50-CPP | High | Likely | No | No | P9 | L2 |
| MEM51-CPP | High | Likely | No | No | P9 | L2 |
| MEM52-CPP | High | Likely | Yes | Yes | P27 | L1 |
| MEM53-CPP | High | Likely | No | No | P9 | L2 |
| MEM54-CPP | High | Likely | No | No | P9 | L2 |
| MEM55-CPP | High | Likely | No | No | P9 | L2 |
| MEM56-CPP | High | Likely | No | No | P9 | L2 |
| MEM57-CPP | Medium | Unlikely | No | No | P2 | L3 |


