[MERGED] libosmocore[master]: Fix potential segfault in msg_dequeue

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Thu Jun 23 20:00:33 UTC 2016


Harald Welte has submitted this change and it was merged.

Change subject: Fix potential segfault in msg_dequeue
......................................................................


Fix potential segfault in msg_dequeue

Change-Id: I06e9c5ba3e00c73a4e52d2583ce3492f236275ce
---
M src/msgb.c
1 file changed, 6 insertions(+), 3 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



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

-- 
To view, visit https://gerrit.osmocom.org/407
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I06e9c5ba3e00c73a4e52d2583ce3492f236275ce
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list