]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Avoid reference to nonexistent array element in ExecInitAgg().
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 2 Jan 2023 21:17:00 +0000 (16:17 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 2 Jan 2023 21:17:00 +0000 (16:17 -0500)
commita02740e53fb7d1668e2d0ea1362743d23211d43d
tree5fe1a0d9364d9ea99f8922b4f249cfcc2a3bc904
parentfdaba0a2d749bff497313b584f86855a1440d43e
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
src/backend/executor/nodeAgg.c