Fix potential segfault in msg_dequeue

Change-Id: I06e9c5ba3e00c73a4e52d2583ce3492f236275ce
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 @@
 		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