security: add a NULL pointer check to fix a server crash.