Check for NULL pointers.  Fixes #178