Re: [BUG] ECPG crash with union type

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jehan-Guillaume de Rorthais <jgdr@dalibo.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-06-25T20:46:05Z
Lists: pgsql-hackers
Jehan-Guillaume de Rorthais <jgdr@dalibo.com> writes:
> One of our customer hit a sigsev with ecpg lately. Their team created a simple
> scenario and point us the origin of the crash in ECPG code. The credit goes to
> them (iMSA) for that work.
> ...
> If setting "$$.type_sizeof = NULL;" is legit for unions (I didn't try to wrap
> my head around this code), maybe this change should be:

>     -       ne->struct_sizeof = struct_sizeof;
>     +       ne->struct_sizeof = struct_sizeof ? mm_strdup(struct_sizeof):NULL;

Yeah, I agree.  Will fix, thanks for the report!

			regards, tom lane



Commits

  1. Fix null-pointer crash in ECPG compiler.

  2. ecpg: fix some memory leakage of data-type-related structures.