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

Hi,

This patch fixes ticket #4994 by avoiding null pointer dereferencing when running CheckOther::checkVariableScope on invalid input. Thanks to consider merging.

Best regards,
  Simon