From d826f1771cdada9009db599a9cf3882192bf0454 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 23 Jun 2016 13:14:02 +0200 Subject: Fix potential segfault in msg_dequeue Change-Id: I06e9c5ba3e00c73a4e52d2583ce3492f236275ce --- src/msgb.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') 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 -- cgit v1.2.3