That there is No salvation Outside the Church is defined dogma and cannot be disputed.
That a Baptism of desire is possible and effective is clear in the example of the good thief:
Luke 23:43
"And Jesus said to him: Amen I say to thee, this day thou shalt be with me in paradise."
The receipt of the truths of the Catholic faith, follows commensurately with correspondence to grace in the interior will, such that it is subject to God and His laws.
John 7:16-17
"Jesus answered them, and said: My doctrine is not mine, but his that sent me. If any man do the will of him; he shall know of the doctrine, whether it be of God, or whether I speak of myself."
Thus also does St Thomas state:
"In all who are in a state of grace, there must needs be rectitude of the will, since grace prepares man's will for good, according to Augustine (Contra Julian. Pelag. iv, 3). Now the will cannot be rightly directed to good, unless there be already some knowledge of the truth, since the object of the will is good understood, as stated in De Anima iii, 7. Again, just as the Holy Ghost directs man's will by the gift of charity, so as to move it directly to some supernatural good; so also, by the gift of understanding, He enlightens the human mind, so that it knows some supernatural truth, to which the right will needs to tend."
On the Gift of Understanding
Therefore, the good thief, after initially rejecting Christ (Matt 27:44) was converted during his crucifixion and was enlightened in mind to belief in Christ:
Luke 23:42
"And he said to Jesus: Lord, remember me when thou shalt come into thy kingdom."
1 Corinthians 12:3
"And no man can say the Lord Jesus, but by the Holy Ghost."
Therefore, if his understanding knew not all the doctrines of the Catholic faith, he had implicit acceptance through what we might call "mother truths", because God has so ordered that some doctrine is taught directly by the Holy Ghost and some by the Church/preachers.
1 Corinthians 2:13
"Which things also we speak, not in the learned words of human wisdom; but in the doctrine of the Spirit"
Hebrews 6:1-2
"Wherefore leaving the word of the beginning of Christ, let us go on to things more perfect, not laying again the foundation of penance from dead works, and of faith towards God, Of the doctrine of baptisms, and imposition of hands..."
Thus failure of consent to Catholic doctrine by heretics and in its cause, is seen as follows:
1 Timothy 6:3-5
"If any man teach otherwise, and consent not to the sound words of our Lord Jesus Christ, and to that doctrine which is according to godliness, He is proud, knowing nothing, but sick about questions and strifes of words; from which arise envies, contentions, blasphemies, evil suspicions, Conflicts of men corrupted in mind, and who are destitute of the truth,"
Thus the good thief was saved because full consent in the will to God's will commensurates with full consent to Catholic doctrine.
Why providence gives some to be saved through a baptism of desire rather than through the orthodox channel of the church is a mystery of predestination, but is some wise ordering of our God of Whom it is written:
1 Timothy 2:4
"Who will have all men to be saved, and to come to the knowledge of the truth."