Guard against null-pointer dereference.

This restores the check that was lost in commit 79562ca (PR #39).