Avoid potential null dereferences.
Merge pull request #50 from dajohi/cmd_null_deref

Avoid potential null dereferences.