In addition to affirming the necessity of baptism, there is a secondary issue (“secondary” in terms of being a derivative not in terms of its importance) from your question which requires serious consideration: If baptism is necessary for salvation, what about those who have never had the opportunity to get baptized due to reasons not within their control or discretion? Will they be saved? These people include the non-believers and believers of other religions, as well as the hypothetical case mentioned in your question, i.e. a believer who died after expressing publicly his faith but before receiving baptism. The Catholic version of your hypothetical case will be a catechumen who died while going through the RCIA process.
Before proceeding to answer this question, I must make something very clear because I don’t want you to think that I know who will be saved and who won’t. A few years ago, I attended a religious funeral in which the religious master in charge of the funeral took a moment to “touch and feel” the body of the deceased and then declared that the happy soul was already in heaven because the person’s body was “nice and soft”. As much as I loved the deceased, I found it hard to believe the religious master's claim. My point is this: Nobody but Jesus can judge; no mere mortal can claim to know how he is going to judge and what his decision will be. Baptized or otherwise, a person stands justified before Jesus only if he judges in favor of the person’s salvation. As holy and faithful to Christ as St. Paul was, he would not even pass judgment on himself and claim that he would stand acquitted (cf. 1 Cor. 4:3-5). For the final judgment rests in the hands of Christ, who judges people’s hidden works from his judgment seat (Romans 2:16, 1 Cor. 4:4, 2 Cor. 5:16).
As far as the non-believers and the believers of other religions who aren’t baptized, the Church’s position is explained by JPII as follows: “For those who are not formally and visibly members of the Church, salvation in Christ is accessible by virtue of a grace which, while having a mysterious relationship to the Church…enlightens them in a way which is accommodated to their spiritual and material situation. This grace comes from Christ; it is the result of his sacrifice and is communicated by the Holy Spirit…” (JPII, Redemptoris mission, 10).
The Catechism offers a similar explanation: “Every man who is ignorant of the Gospel of Christ and of his Church, but seeks the truth and does the will of God in accordance with his understanding of it, can be saved. It may be supposed that such persons would have desired Baptism explicitly if they had known its necessity” (CCC 1260). The same reasoning can also be applied to the fore-mentioned catechumen and the person in your hypothetical case.