As noted in under undefined behavior 179 of in Annex J of the C Standard [ISO/IEC 9899:2011], the behavior of a program is undefined when
...
This compliant solution eliminates the possibility of str
, referencing non-dynamic nondynamic memory when it is supplied to free()
:
...
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
MEM34-C | highHigh | likelyLikely | mediumMedium | P18 | L1 |
Automated Detection
Tool | Version | Checker | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
Can detect some violations of this rule. | |||||||||
| BAD_FREE | Identifies calls to | |||||||
| FNH.MIGHT | ||||||||
| 483 S | Fully implemented |
...
CERT C Secure Coding Standard | MEM31-C. Free dynamically allocated memory exactly once |
CERT C++ Secure Coding Standard | MEM34-CPP. Only free memory allocated dynamically |
ISO/IEC TS 17961 (Draft) | Reallocating or freeing memory that was not dynamically allocatied [xfree] |
MITRE CWE | CWE-590, Free of invalid pointer not on the heap |
...
[Seacord 2013] | Chapter 4, "Dynamic Memory Management" |
[ISO/IEC 9899:2011] | Annex J, subclause J.2, "Undefined behaviorBehavior" |
...