[PATCH 1/1] libctrl: only free() msgb if it was alloc()ed

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/OpenBSC@lists.osmocom.org/.

Alexander Huemer alexander.huemer at xx.vu
Tue Oct 11 20:25:21 UTC 2011


Before this patch a SIGABRT was caused when doing e.g.:
$ ncat 127.0.0.1 4249
^C
---
 openbsc/src/libctrl/control_if.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/openbsc/src/libctrl/control_if.c b/openbsc/src/libctrl/control_if.c
index 8198ae6..c395b08 100644
--- a/openbsc/src/libctrl/control_if.c
+++ b/openbsc/src/libctrl/control_if.c
@@ -208,7 +208,7 @@ static int handle_control_read(struct osmo_fd * bfd)
 	struct ctrl_connection *ccon;
 	struct ipaccess_head *iph;
 	struct ipaccess_head_ext *iph_ext;
-	struct msgb *msg;
+	struct msgb *msg = NULL;
 	struct ctrl_cmd *cmd;
 	struct ctrl_handle *ctrl = bfd->data;
 
@@ -269,7 +269,8 @@ static int handle_control_read(struct osmo_fd * bfd)
 
 err:
 	control_close_conn(ccon);
-	msgb_free(msg);
+	if (msg)
+		msgb_free(msg);
 	return ret;
 }
 
-- 
1.7.7





More information about the OpenBSC mailing list