Add missing NULL check in cmd_lastlog

Closes #961