Preempting an attempt to dereference null