Pius XII was a legitimate pope. Popes can err in fallible speeches and docuмents. No legitimate pope can err in dogmatic statements and docuмents addressed to the whole church, this is why we can trust in the church teachings definitely. Pope Pius XII never taught any heresy dogmatically, he did however, teach heresies in fallible speeches, such as nfp (natural family planning), and, as you said, if he did talk about baptism of desire, which of course, is another heresy.
It's a fact that no Pope in the history of the Catholic Church has taught dogmatically that one can be saved with baptism of blood or with baptism of desire. There are, however, numerous dogmatic definitions clarifying the fact that one is in need of the actual element of water for salvation, without exception.
Saints and Doctors of the Church can be wrong and have been wrong in much, teaching baptism of blood and baptism of desire. Saint Thomas Aquinas believed and wrote down that the blessed Virgin Mary was conceived in sin, (which was before the dogma of the immaculate conception was defined), further proving the fallibility of Saints and Doctors of the Church, yet again affirming the validity and infallibility of dogmatic definitions of popes.