pgsql: Guard against null plan pointer in CachedPlanIsSimplyValid().

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Guard against null plan pointer in CachedPlanIsSimplyValid().
Date: 2023-07-20 18:24:01
Message-ID: E1qMYJk-000UQF-Pi@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(at)telsasoft(dot)com

Branch
------
REL_16_STABLE

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

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

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2023-07-21 03:08:25 pgsql: Fix worker_spi when launching workers without shared_preload_lib
Previous Message Daniel Gustafsson 2023-07-20 15:20:38 pgsql: Revert "Add notBefore and notAfter to SSL cert info display"