pgsql: Fix list_copy_head() with empty Lists

From: David Rowley <drowley(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix list_copy_head() with empty Lists
Date: 2023-04-20 22:03:02
Message-ID: E1ppcMn-00436i-J7@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix list_copy_head() with empty Lists

list_copy_head() given an empty List would crash from trying to
dereference the List to obtain its length. Since NIL is how we represent
an empty List, we should just be returning another empty List in this
case.

list_copy_head() is new to v16, so let's fix it now before too many people
start coding around the buggy NIL behavior.

Reported-by: Miroslav Bendik
Discussion: https://postgr.es/m/CAPoEpV02WhawuWnmnKet6BqU63bEu7oec0pJc=nKMtPsHMzTXQ@mail.gmail.com

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/63a03aea6bc89060010255e8e61c83f95e1daec8

Modified Files
--------------
src/backend/nodes/list.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message David Rowley 2023-04-20 22:07:46 Re: pgsql: Fix list_copy_head() with empty Lists
Previous Message Andrew Dunstan 2023-04-20 19:37:43 Re: pgsql: Further cleanup of autoconf output files for GSSAPI changes.