Ticket #5024: Don't crash upon invalid code when checking auto variables

Hello,

This trivial patch fixes the case initially reported in this ticket (the second part is rather different and would require a separate ticket IMHO). Thanks to consider merging.

Best regards,
  Simon