Doctor of the Church St. Francis de Sales (1) totally confirmed beyond any doubt the possibility of a heretical pope and what must be done by the Church in such a situation:
“The Pope… WHEN he is EXPLICITLY a heretic, he falls ipso facto from his dignity and out of the Church, and the Church MUST either deprive him, or, as some say, declare him deprived, of his Apostolic See.“
_________________________________
(1) The Catholic Controversy, by St. Francis de Sales, Pages 305-306.