Skip to content

Commit

Permalink
adlist: fix listJoin() to handle empty lists.
Browse files Browse the repository at this point in the history
  • Loading branch information
antirez committed May 3, 2017
1 parent 6798736 commit 79226cb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/adlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,14 @@ void listRotate(list *list) {
/* Add all the elements of the list 'o' at the end of the
* list 'l'. The list 'other' remains empty but otherwise valid. */
void listJoin(list *l, list *o) {
l->tail->next = o->head;
o->head->prev = l->tail;
if (o->head)
o->head->prev = l->tail;

if (l->tail)
l->tail->next = o->head;
else
l->head = o->head;

l->tail = o->tail;

/* Setup other as an empty list. */
Expand Down

0 comments on commit 79226cb

Please sign in to comment.