Ticket #4994: Don't crash when checking variable scope for invalid input.
Merge pull request #168 from simartin/ticket_4994

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