[PATCH] 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/.

Max gerrit-no-reply at lists.osmocom.org
Thu Jun 23 15:10:09 UTC 2016


Review at  https://gerrit.osmocom.org/407

Fix potential segfault in msg_dequeue

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


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/07/407/1

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: newchange
Gerrit-Change-Id: I06e9c5ba3e00c73a4e52d2583ce3492f236275ce
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list