Fix a possible crash due to a null pointer.