Sanitize against NULL in some free-like functions.