Guard against null-pointer dereference.

This restores the check that was lost in commit 79562ca.
Merge pull request #40 from bska/nullptr-deref

Guard against null-pointer dereference.