Content-Length: 264206 | pFad | http://github.com/postgrespro/postgres/commit/9089287aa037fdecb5a52cec1926e5ae9569e9f9

EF Guard against null plan pointer in CachedPlanIsSimplyValid(). · postgrespro/postgres@9089287 · GitHub
Skip to content

Commit 9089287

Browse files
committed
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
1 parent 29a0ccb commit 9089287

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/backend/utils/cache/plancache.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,9 @@ CachedPlanIsSimplyValid(CachedPlanSource *plansource, CachedPlan *plan,
14401440
* that here we *do* check plansource->is_valid, so as to force plan
14411441
* rebuild if that's become false.
14421442
*/
1443-
if (!plansource->is_valid || plan != plansource->gplan || !plan->is_valid)
1443+
if (!plansource->is_valid ||
1444+
plan == NULL || plan != plansource->gplan ||
1445+
!plan->is_valid)
14441446
return false;
14451447

14461448
Assert(plan->magic == CACHEDPLAN_MAGIC);

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/9089287aa037fdecb5a52cec1926e5ae9569e9f9

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy