pgsql: Avoid reference to nonexistent array element in ExecInitAgg().

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Avoid reference to nonexistent array element in ExecInitAgg().
Date: 2023-01-02 21:17:19
Message-ID: E1pCSBK-001jTa-So@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/92957ed98c5c565362ce665266132a7f08f6b0c0

Modified Files
--------------
src/backend/executor/nodeAgg.c | 5 +++++
1 file changed, 5 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2023-01-03 01:21:33 pgsql: perl: Hide warnings inside perl.h when using gcc compatible comp
Previous Message Bruce Momjian 2023-01-02 20:01:14 pgsql: Update copyright for 2023