E5A5 Avoid reference to nonexistent array element in ExecInitAgg(). · postgres/postgres@982b9b1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 982b9b1

Browse files
committed
Avoid reference to nonexistent array element in ExecInitAgg().
When considering an empty grouping set, we fetched phasedata->eqfunctions[-1]. Because the eqfunctions array is palloc'd, that would always be an aset pointer in released versions, and thus the code accidentally failed to malfunction (since it would do nothing unless it found a null pointer). Nonetheless this seems like trouble waiting to happen, so add a check for length == 0. It's depressing that our valgrind testing did not catch this. Maybe we should reconsider the choice to not mark that word NOACCESS? Richard Guo Discussion: https://postgr.es/m/CAMbWs4-vZuuPOZsKOYnSAaPYGKhmacxhki+vpOKk0O7rymccXQ@mail.gmail.com
1 parent ef3de55 commit 982b9b1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/backend/executor/nodeAgg.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2377,6 +2377,11 @@ ExecInitAgg(Agg *node, EState *estate, int eflags)
23772377
{
23782378
int length = phasedata->gset_lengths[i];
23792379

2380+
/* nothing to do for empty grouping set */
2381+
if (length == 0)
2382+
continue;
2383+
2384+
/* if we already had one of this length, it'll do */
23802385
if (phasedata->eqfunctions[length - 1] != NULL)
23812386
continue;
23822387

0 commit comments

Comments
 (0)
0