That doesn't
mean that only those who have been formally baptized can be saved. From
very early on, the Church recognized that there are two other types of
baptism besides the baptism of water.
The baptism of desire applies both to those who, while wishing to be
baptized, die before receiving the sacrament and "Those who, through no
fault of their own, do not know the Gospel of Christ or His Church, but
who nevertheless seek God with a sincere heart, and, moved by grace, try
in their actions to do His will as they know it through the dictates of
conscience" (Constitution on the Church, Second Vatican Council).