Same here - check directly for the null pointer and exit on error, remove the check for the null pointer below.