Add a missing null pointer check