Overriding 'malloc' using the LD_PRELOAD mechanism
How can LD_PRELOAD
be used to set ptr
to NULL or to any other memory address in order to avoid dangling pointer exploits.
void free(void *ptr)
{
real_free(ptr);
ptr = NULL // will only set local ptr to NULL
}