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

Commite35ded2

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 parent2584639 commite35ded2

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
@@ -1593,11 +1593,11 @@ list_copy_head(const List *oldlist, int len)
15931593
{
15941594
List*newlist;
15951595

1596-
len=Min(oldlist->length,len);
1597-
1598-
if (len <=0)
1596+
if (oldlist==NIL||len <=0)
15991597
returnNIL;
16001598

1599+
len=Min(oldlist->length,len);
1600+
16011601
newlist=new_list(oldlist->type,len);
16021602
memcpy(newlist->elements,oldlist->elements,len*sizeof(ListCell));
16031603

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp