...
Because malloc() is only called if p is NULL when entering the if clause, free() might be called with a pointer to local data not allocated by malloc(). (see See guideline MEM34-C. Only free memory allocated dynamically.) . This is partially due to the uncertainty of whether malloc() is actually called or not.
...
Recommendation | Severity | Likelihood | Remediation Cost | Priority | Level |
|---|---|---|---|---|---|
EXP02-C | low | unlikely | medium | P2 | L3 |
Automated Detection
...
Tool | Version | Checker | Description |
|---|---|---|---|
|
...
|
|
| ||||||||
|
|
|
|
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Other Languages
Related Guidelines
This rule appears in the C++ Secure Coding Standard as : EXP02-CPP. Be aware of the short-circuit behavior of the logical AND and OR operators.
Bibliography
| Wiki Markup |
|---|
\[[CWE|AA. Bibliography#CWE]\] [CWE-768|http://cwe.mitre.org/data/definitions/768.html]: Incorrect Short Circuit Evaluation \[[ISO/IEC 9899:1999|AA. Bibliography#ISO/IEC 9899-1999]\] Section 6.5.13, "Logical AND operator," and Section 6.5.14, "Logical OR operator" |
...