Do not dereference NULL. Fix for bb#587