Fix problem when pointer is nullptr.