Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: The C Standard uses null as an English adjective, NULL as a C noun.

Dangling pointers can lead to exploitable double-free and access-freed-memory vulnerabilities. A simple yet effective way to eliminate dangling pointers and avoid many memory related vulnerabilities is to set pointers to NULL after they have been freed, or to another valid object.

Calling free() on a null pointer results in no action being taken by free().

...

As stated above, calling free() on a null pointer results in no action being taken by free(). Setting message to NULL after it has been freed eliminates the possibility that the message pointer cannot be used to free the same memory more than once.

...

Risk Assessment

Setting pointers to null NULL or to another valid value after memory has been freed is a simple and easily implemented solution for reducing dangling pointers. Dangling pointers can result in freeing memory multiple times or in writing to memory that has already been freed. Both of these problems can lead to an attacker executing arbitrary code with the permissions of the vulnerable process.

...