Fixed a bad (cast) on a NULL pointer