Now a man is not bound to receive Baptism as soon as he makes up his mind to be baptized; and so*** he would not sin mortally, if he were not baptized at once***: nor is there any fixed time beyond which, if he defer Baptism, he would incur a mortal sin. Nevertheless the delay of Baptism may amount to a mortal sin, or it may not, and this depends on the cause of the delay, since, as the Philosopher says (Phys. viii, text. 15), the will does not defer doing what it wills to do, except for a reasonable cause. Wherefore if the cause of the delay of Baptism has a mortal sin connected with it, e.g. ***if a man put off being baptized through contempt, or some like motive, the delay will be a mortal sin, but otherwise not: and the same seems to apply to confession ***which is not more necessary than Baptism. Moreover, since man is bound to fulfill in this life those things that are necessary for salvation, therefore, if he be in danger of death, he is bound, even absolutely, then and there to make his confession or to receive Baptism. For this reason too, James proclaimed at the same time the commandment about making confession and that about receiving Extreme Unction (James 5:14-16). Therefore the opinion seems probable of those who say that a man is not bound to confess at once, though it is dangerous to delay.
[St. Thomas Aquinas, Summa Theologica, suppl., 6, 5]