summaryrefslogtreecommitdiff
path: root/src/adlist.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/adlist.c')
-rw-r--r--src/adlist.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/adlist.c b/src/adlist.c
index 96575c72e..0f2e4a559 100644
--- a/src/adlist.c
+++ b/src/adlist.c
@@ -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. */