Vince Vielhaber <vev(at)michvhf(dot)com> writes:
> Where do we check that this:
> result = (text *) palloc(tlen);
> is even successful?
palloc elogs if it can't allocate the space; it's unlike malloc in that
respect. I believe it also has a guard to reject requests > 1Gb, so
I think it's reasonably proof against internal arithmetic overflows.
This problem is strictly repeat's error, not palloc's.
regards, tom lane