Ticket #4994: Don't crash when checking variable scope for invalid input.