aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2016-06-23 13:14:02 +0200
committerHarald Welte <laforge@gnumonks.org>2016-06-23 20:00:33 +0000
commitd826f1771cdada9009db599a9cf3882192bf0454 (patch)
tree79fb12f86e6b22bd356f9ddb1de5d75cfacec283
parente0a7d9e2c220e5544ee8982c78851ff40ac425bc (diff)
Fix potential segfault in msg_dequeue
-rw-r--r--src/msgb.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/msgb.c b/src/msgb.c
index f09da90..ea8dc82 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