Fix a potential null dereference bug.