Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added extra information about the exception not complying with DCL31-C

...

On an LLP64/LP64 platform, such as Microsoft Windows, the above code will eventually cause an access violation when dereferencing ptr in the loop.  Note that the code also does not comply with DCL31-C. Declare identifiers before using them by using an implicit declaration of malloc().

Risk Assessment

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++.

...