Fix a potential invalid pointer reference.