Hi!
While I think that OP's patch is close to being correct, I also agree
with Tom and Alexander that the scope of this UB is outside of
Postgres code. So I fully agree with the final approach. Thanks to
everyone in this thread!
Regards,
Pavel Borisov