Bug fix: don't dereference a null pointer