summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/msgb.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/msgb.c b/src/msgb.c
index f09da90d..ea8dc827 100644
--- a/src/msgb.c
+++ b/src/msgb.c
@@ -101,9 +101,12 @@ struct msgb *msgb_dequeue(struct llist_head *queue)
return NULL;
lh = queue->next;
- llist_del(lh);
-
- return llist_entry(lh, struct msgb, list);
+
+ if (lh) {
+ llist_del(lh);
+ return llist_entry(lh, struct msgb, list);
+ } else
+ return NULL;
}
/*! \brief Re-set all message buffer pointers