...
Calling malloc( n )
allocates memory for an object whose size is n
and returns either a null pointer or a pointer to the allocated memory. A program can implicitly convert the pointer that malloc()
returns into a different pointer type.
Code that follows this recommendation will compile and execute equally well in C++.
Non-Compliant Code Example
...
Failing to cast the result of a memory allocation function call into a pointer to the allocated type can result in inadvertent pointer conversions. Code that follows this recommendation will compile and execute equally well in C++.
Recommendation | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
MEM02-A | 1 (low) | 1 (unlikely) | 3 (low) | P3 | L3 |
...