Use After Free
Example 1: C
Vulnerable Code:
Reason for vulnerability: Using memory after it has been freed, leading to undefined behavior.
Fixed Code:
Reason for fix: Set the pointer to NULL
after freeing it to prevent use after free.
Example 2: C++
Vulnerable Code:
Reason for vulnerability: Using memory after it has been freed, leading to undefined behavior.
Fixed Code:
Reason for fix: Set the pointer to nullptr
after deleting it to prevent use after free.
Last updated