Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit63a03ae

Browse files
committed
Fix list_copy_head() with empty Lists
list_copy_head() given an empty List would crash from trying todereference the List to obtain its length. Since NIL is how we representan empty List, we should just be returning another empty List in thiscase.list_copy_head() is new to v16, so let's fix it now before too many peoplestart coding around the buggy NIL behavior.Reported-by: Miroslav BendikDiscussion:https://postgr.es/m/CAPoEpV02WhawuWnmnKet6BqU63bEu7oec0pJc=nKMtPsHMzTXQ@mail.gmail.com
1 parent94d73f9 commit63a03ae

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

‎src/backend/nodes/list.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,11 +1553,11 @@ list_copy_head(const List *oldlist, int len)
15531553
{
15541554
List*newlist;
15551555

1556-
len=Min(oldlist->length,len);
1557-
1558-
if (len <=0)
1556+
if (oldlist==NIL||len <=0)
15591557
returnNIL;
15601558

1559+
len=Min(oldlist->length,len);
1560+
15611561
newlist=new_list(oldlist->type,len);
15621562
memcpy(newlist->elements,oldlist->elements,len*sizeof(ListCell));
15631563

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp