From cc37bd8b6acfc71bc5d6e56ac00212b305a0ea71 Mon Sep 17 00:00:00 2001 From: Alexander Kuznetsov Date: Thu, 10 Oct 2024 17:38:10 +0300 Subject: [PATCH] Check for tuplestorestate nullness before dereferencing tuplestorestate can be NULL when calculating eof_tuplestore, where tuplestorestate is dereferenced by tuplestore_gettuple(). Add check for nullness before dereferencing. Found by ALT Linux Team with Svace. --- src/backend/executor/nodeMaterial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/executor/nodeMaterial.c b/src/backend/executor/nodeMaterial.c index 9798bb753651..a5cd99639071 100644 --- a/src/backend/executor/nodeMaterial.c +++ b/src/backend/executor/nodeMaterial.c @@ -95,7 +95,7 @@ ExecMaterial(PlanState *pstate) * to return the one before that, if possible. So do an extra * fetch. */ - if (!tuplestore_advance(tuplestorestate, forward)) + if (tuplestorestate == NULL || !tuplestore_advance(tuplestorestate, forward)) return NULL; /* the tuplestore must be empty */ } eof_tuplestore = false;