Skip to content

Commit 92957ed

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 c8e1ba7 commit 92957ed

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/backend/executor/nodeAgg.c

+5
Original file line numberDiff line numberDiff line change
@@ -3494,6 +3494,11 @@ ExecInitAgg(Agg *node, EState *estate, int eflags)
34943494
{
34953495
int length = phasedata->gset_lengths[k];
34963496

3497+
/* nothing to do for empty grouping set */
3498+
if (length == 0)
3499+
continue;
3500+
3501+
/* if we already had one of this length, it'll do */
34973502
if (phasedata->eqfunctions[length - 1] != NULL)
34983503
continue;
34993504

0 commit comments

Comments
 (0)