pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Don't leak malloc'd strings when a GUC setting is rejected.
Date: Fri, 19 Mar 2021 02:23:41 +0000
Message-ID: <E1lN4nd-0001ob-LL@gemulon.postgresql.org> (raw)

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
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/26a3ae06d85c835c04642c08e304e11821587ad2

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



view thread (6+ messages)  latest in thread

Message-ID: <E1lN4nd-0001ob-LL@gemulon.postgresql.org>
Permalink:  ../E1lN4nd-0001ob-LL@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1lN4nd-0001ob-LL@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Don't leak malloc'd strings when a GUC setting is rejected.
  In-Reply-To: <E1lN4nd-0001ob-LL@gemulon.postgresql.org>
  References: <E1lN4nd-0001ob-LL@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox