Re: [PATCH] Check for TupleTableSlot nullness before dereferencing

Daniel Gustafsson <daniel@yesql.se>

From: Daniel Gustafsson <daniel@yesql.se>
To: kuznetsovam@altlinux.org
Cc: PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>, egori@altlinux.org, nickel@altlinux.org
Date: 2024-10-03T09:48:37Z
Lists: pgsql-hackers
> On 3 Oct 2024, at 09:47, Alexander Kuznetsov <kuznetsovam@altlinux.org> wrote:
> 
> Hello everyone,
> 
> I'd like to propose adding check for nullness of
> TupleTableSlot before dereferencing it in /src/backend/executor/nodeAgg.c
> 
> It is done in the same manner other TupleTableSlots are checked,
> but was probably left unseen because slot1 and slot2 variables
> can be swapped during function execution.

From a quick reading we can only reach there after evaluating an expression, so
can it really be null though?  This code hasn't changed all that much since
2009, if there was a reachable segfault on a null pointer deref I have a
feeling we'd heard about it by now so some extra care seems warranted to ensure
it's not a static analyzer false positive.

--
Daniel Gustafsson