]> git.ipfire.org Git - thirdparty/postgresql.git/commit
In array_position()/array_positions(), beware of empty input array.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 4 May 2023 15:48:23 +0000 (11:48 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 4 May 2023 15:48:23 +0000 (11:48 -0400)
commit580df507896351a0ebb5a09c2c84c0eac7b6740f
treec210fd306e56246b014d4411e678c96f6a72ca9d
parentb7fcf3824b42c43458121ada1f74e111ca987d4d
In array_position()/array_positions(), beware of empty input array.

These functions incautiously fetched the array's first lower bound
even when the array is zero-dimensional, thus fetching the word
after the allocated array space.  While almost always harmless,
with very bad luck this could result in SIGSEGV.  Fix by adding
an early exit for empty input.

Per bug #17920 from Alexander Lakhin.

Discussion: https://postgr.es/m/17920-f7c228c627b6d02e%40postgresql.org
src/backend/utils/adt/array_userfuncs.c