pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Don't test already-referenced pointer for nullness
Date: Tue, 16 Jan 2024 11:30:15 +0000
Message-ID: <E1rPhe3-001fwE-EH@gemulon.postgresql.org> (raw)

Don't test already-referenced pointer for nullness

Commit b8ba7344e9eb added in PQgetResult a derefence to a pointer
returned by pqPrepareAsyncResult(), before some other code that was
already testing that pointer for nullness.  But since commit
618c16707a6d (in Postgres 15), pqPrepareAsyncResult() doesn't ever
return NULL (a statically-allocated result is returned if OOM).  So in
branches 15 and up, we can remove the redundant pointer check with no
harm done.

However, in branch 14, pqPrepareAsyncResult() can indeed return NULL if
it runs out of memory.  Fix things there by adding a null pointer check
before dereferencing the pointer.  This should hint Coverity that the
preexisting check is not redundant but necessary.

Backpatch to 14, like b8ba7344e9eb.

Per Coverity.

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/2b656cbd2f24edb7e2964fa3f71ca253ee9d81d8

Modified Files
--------------
src/interfaces/libpq/fe-exec.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)



view thread (4+ messages)  latest in thread

Message-ID: <E1rPhe3-001fwE-EH@gemulon.postgresql.org>
Permalink:  ../E1rPhe3-001fwE-EH@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1rPhe3-001fwE-EH@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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: alvherre@alvh.no-ip.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Don't test already-referenced pointer for nullness
  In-Reply-To: <E1rPhe3-001fwE-EH@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