Popes are human beings, and they can sin. What is perhaps more astonishing is that more of them weren't utterly evil. From a list of over 200 popes, there are remarkably few who have lived the high life. He was a sinner - and yet he did not try to change the deposit of God's truth at all. The truth of God protected even him from damaging the transmission of the Faith to all believers.
Popes can be dreadful.
It is the office of Pope which is guarded from changing the Faith, not the man. Nor can anyone else. It's not ours to change, because it belongs to God.