]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix null-pointer crash in ECPG compiler.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 25 Jun 2026 20:58:29 +0000 (16:58 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 25 Jun 2026 20:58:29 +0000 (16:58 -0400)
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 <jgdr@dalibo.com>)
Author: Jehan-Guillaume de Rorthais <jgdr@dalibo.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/20260625114849.34b2148e@karst
Backpatch-through: 18

src/interfaces/ecpg/preproc/type.c

index eec87c9cae108a75ad76ee3bc841cafa5f69136e..7b40c61f782a60aaa602b74f67ab238ffa48e50b 100644 (file)
@@ -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;
 }