Add missing NULL check in cmd_lastlog

As the loop does the check, the if should too.