The Catholic teaching on this subject is correct; the Book of Mormon agrees:
Mosiah 3:
11 For behold, and also his blood atoneth for the sins of those who have fallen by the transgression of Adam, who have died
not knowing the will of God concerning them, or who have ignorantly sinned.
12 But wo, wo unto him who
knoweth that he rebelleth against God! For salvation cometh to none such except it be through repentance and faith on the Lord Jesus Christ.
D&C 137:
7 Thus came the voice of the Lord unto me, saying: All who have died without a knowledge of this gospel, who would have received it if they had been permitted to tarry, shall be heirs of the celestial kingdom of God;
8 Also all that shall die henceforth without a knowledge of it, who would have received it with all their hearts, shall be heirs of that kingdom;
9 For I, the Lord, will judge all men according to their works, according to the desire of their hearts.