[BUG #7086] Added check to prevent accessing a undefined variable.