pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Daniel Gustafsson <dgustafsson@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Guard against reallocation failure in pg_regress
Date: Thu, 24 Feb 2022 19:59:21 +0000
Message-ID: <E1nNKGm-000Cmy-7f@gemulon.postgresql.org> (raw)

Guard against reallocation failure in pg_regress

realloc() will return NULL on a failed reallocation, so the destination
pointer must be inspected to avoid null pointer dereference.  Further,
assigning the return value to the source pointer leak the allocation in
the case of reallocation failure.  Fix by using pg_realloc instead which
has full error handling.

Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/9FC7E603-9246-4C62-B466-A39CFAF454AE@yesql.se

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/31d8d4740ffb21c9898a21b5018c31e92af6935d

Modified Files
--------------
src/test/regress/pg_regress.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



Message-ID: <E1nNKGm-000Cmy-7f@gemulon.postgresql.org>
Permalink:  ../E1nNKGm-000Cmy-7f@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1nNKGm-000Cmy-7f@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: dgustafsson@postgresql.org
  Subject: Re: pgsql: Guard against reallocation failure in pg_regress
  In-Reply-To: <E1nNKGm-000Cmy-7f@gemulon.postgresql.org>
  References: <E1nNKGm-000Cmy-7f@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