Setting pointer to NULL to prevent 'double free'