Versions Compared

Key

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

...

In nonconforming implementations, calling free on the original pointer might result in a double-free vulnerability. However, not calling free on the original pointer might result in a memory leak.

Compliant

...

Solution (realloc())

In this compliant solution, allocations of 0 bytes are prevented, ensuring that p is freed exactly once:

...

Related Vulnerabilities

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

...