Fix trim_array() for zero-dimensional array argument. The code tried to access ARR_DIMS(v)[0] and ARR_LBOUND(v)[0] whether or not those values exist. This made the range check on the "n" argument unstable --- it might or might not fail, and if it did it would report garbage for the allowed upper limit. These bogus accesses would probably annoy Valgrind, and if you were very unlucky even lead to SIGSEGV.
Report and fix by Martin Kalcher. Back-patch to v14 where this function was added. Discussion: https://postgr.es/m/[email protected] Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/e71d4254f710bef53fa40d0b49b5af9bad10ce40 Modified Files -------------- src/backend/utils/adt/arrayfuncs.c | 9 ++++++--- src/test/regress/expected/arrays.out | 2 ++ src/test/regress/sql/arrays.sql | 1 + 3 files changed, 9 insertions(+), 3 deletions(-)
