Deallocation ends the former access validity
Dynamic allocation makes storage available for use; deallocation permits its manager to recycle or reallocate it. A pointer retaining the old address does not keep the former object alive. Later reads or writes can access invalid storage.
An immediate crash is not required. SEI CERT explains that freed contents can appear unchanged before changing unexpectedly. Depending on this appearance makes the defect sensitive to allocation order and runtime conditions rather than establishing valid behavior.
The final access must precede release
A linked-list cleanup illustrates the ordering issue: freeing the current node before reading its next field accesses freed storage. Saving the successor first and then freeing the node establishes a different, valid ordering.
Multiple holders complicate responsibility when one path releases an object and another retains access. Ownership, borrowing, or managed shared holders should align release with permitted uses. Clearing one pointer variable alone does not account for other existing aliases.
Diagnose access and resource responsibility
AddressSanitizer’s example allocates an array, deletes it, and then reads an element. Its report identifies the access and earlier allocation and release sites, helping connect operations separated in the code.
Avoiding every release is not a general repair because it can replace invalid access with leakage. The required lifetime and final users must be identified. Transferred ownership, managed shared ownership, or copying needed data offer different designs with different costs and constraints.