From: Tom Lane Date: Thu, 25 Jun 2026 20:58:29 +0000 (-0400) Subject: Fix null-pointer crash in ECPG compiler. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f5e0b22e5eabf7b794b5059efa9454ba3616afe;p=thirdparty%2Fpostgresql.git Fix null-pointer crash in ECPG compiler. When compiling a DECLARE section containing a union nested inside a struct, ecpg passes a null value for struct_sizeof to ECPGmake_struct_type. I (tgl) didn't foresee that case in commit 0e6060790, and wrote an unprotected mm_strdup() call. Reported-by: iMSA (via Jehan-Guillaume de Rorthais ) Author: Jehan-Guillaume de Rorthais Reviewed-by: Tom Lane Discussion: https://postgr.es/m/20260625114849.34b2148e@karst Backpatch-through: 18 --- diff --git a/src/interfaces/ecpg/preproc/type.c b/src/interfaces/ecpg/preproc/type.c index eec87c9cae1..7b40c61f782 100644 --- a/src/interfaces/ecpg/preproc/type.c +++ b/src/interfaces/ecpg/preproc/type.c @@ -101,7 +101,7 @@ ECPGmake_struct_type(struct ECPGstruct_member *rm, enum ECPGttype type, ne->type_name = mm_strdup(type_name); ne->u.members = ECPGstruct_member_dup(rm); - ne->struct_sizeof = mm_strdup(struct_sizeof); + ne->struct_sizeof = struct_sizeof ? mm_strdup(struct_sizeof) : NULL; return ne; }