pgsql: Don't leak malloc'd strings when a GUC setting is rejected.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Don't leak malloc'd strings when a GUC setting is rejected.
Date: 2021-03-19 02:23:41
Message-ID: E1lN4nd-0001nx-F9@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Don't leak malloc'd strings when a GUC setting is rejected.

Because guc.c prefers to keep all its string values in malloc'd
not palloc'd storage, it has to be more careful than usual to
avoid leaks. Error exits out of string GUC hook checks failed
to clear the proposed value string, and error exits out of
ProcessGUCArray() failed to clear the malloc'd results of
ParseLongOption().

Found via valgrind testing.
This problem is ancient, so back-patch to all supported branches.

Discussion: https://postgr.es/m/3816764.1616104288@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/377b7a83007d277d32ef19f7c7590c8668d504cb

Modified Files
--------------
src/backend/utils/misc/guc.c | 71 +++++++++++++++++++++++++++++---------------
1 file changed, 47 insertions(+), 24 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2021-03-19 02:30:13 pgsql: Fix comments in postmaster.c.
Previous Message Tomas Vondra 2021-03-19 01:17:52 pgsql: Fix TAP test for remove_temp_files_after_crash