fix potential nul pointer dereference

This commit is contained in:
Richard Frith-Macdonald 2021-01-14 09:29:42 +00:00
parent 6eb08935ea
commit 2a1ec7970c

View file

@ -372,7 +372,7 @@ GSLinkedListInsertAfter(GSListLink *link, GSLinkedList *list, GSListLink *at)
{ {
at = list->tail; at = list->tail;
} }
link->next = at->next; link->next = at ? at->next : nil;
if (nil == link->next) if (nil == link->next)
{ {
list->tail = link; list->tail = link;
@ -381,7 +381,10 @@ GSLinkedListInsertAfter(GSListLink *link, GSLinkedList *list, GSListLink *at)
{ {
link->next->previous = link; link->next->previous = link;
} }
if (at)
{
at->next = link; at->next = link;
}
link->previous = at; link->previous = at;
} }
link->owner = list; link->owner = list;