Prevent accessing freed memory in failure case.