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: Guard against null plan pointer in CachedPlanIsSimplyValid().
Date: Thu, 20 Jul 2023 18:24:01 +0000
Message-ID: <E1qMYJk-000UQI-QI@gemulon.postgresql.org> (raw)

Guard against null plan pointer in CachedPlanIsSimplyValid().

If both the passed-in plan pointer and plansource->gplan are
NULL, CachedPlanIsSimplyValid would think that the plan pointer
is possibly-valid and try to dereference it.  For the one extant
call site in plpgsql, this situation doesn't normally happen
which is why we've not noticed. However, it appears to be possible
if the previous use of the cached plan failed, as per report from
Justin Pryzby.  Add an extra check to prevent crashing.
Back-patch to v13 where this code was added.

Discussion: https://postgr.es/m/ZLlV+STFz1l/WhAQ@telsasoft.com

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/fbaf65cd65f4f0810dab9f2b3e840e68d8b959eb

Modified Files
--------------
src/backend/utils/cache/plancache.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)



view thread (5+ messages)  latest in thread

Message-ID: <E1qMYJk-000UQI-QI@gemulon.postgresql.org>
Permalink:  ../E1qMYJk-000UQI-QI@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1qMYJk-000UQI-QI@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: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Guard against null plan pointer in CachedPlanIsSimplyValid().
  In-Reply-To: <E1qMYJk-000UQI-QI@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