Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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-C

Low

Unlikely

Low

P3

L3

Automated Detection

Tool

Version

Checker

Description

Compass/ROSE

 

 



Can detect some violations of this recommendation when checking EXP36-C. Do not cast pointers into more strictly aligned pointer types

ECLAIR
Include Page
ECLAIR_V
ECLAIR_V
CC2.MEM02Fully implemented
Polyspace Bug Finder

Include Page
Polyspace Bug Finder

R2016a

_V
Polyspace Bug Finder_V

Wrong allocated object size for cast

Wrong type used in sizeof

Allocated memory does not match destination pointer

sizeof argument does not match pointer type

PRQA QA-C
Include Page
PRQA QA-C_v
PRQA QA-C_v
0695Fully implemented

Related Vulnerabilities

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

Related Guidelines

Bibliography

...


...