[PATCH] libosmocore[master]: memleak: _gsmtap_raw_output(): free msg in case of vsnprintf...

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/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Fri Feb 16 00:36:11 UTC 2018


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

memleak: _gsmtap_raw_output(): free msg in case of vsnprintf failure

Don't just return, free the allocated msg first.

Change-Id: I51431ae7baca33ce5bab085cc3efe25f1a10b6d1
---
M src/logging_gsmtap.c
1 file changed, 3 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/15/6515/1

diff --git a/src/logging_gsmtap.c b/src/logging_gsmtap.c
index c53a0ab..f17f292 100644
--- a/src/logging_gsmtap.c
+++ b/src/logging_gsmtap.c
@@ -99,8 +99,10 @@
 	golh->ts.usec = osmo_htonl(tv.tv_usec);
 
 	rc = vsnprintf((char *) msg->tail, msgb_tailroom(msg), format, ap);
-	if (rc < 0)
+	if (rc < 0) {
+		msgb_free(msg);
 		return;
+	}
 	msgb_put(msg, rc);
 
 	rc = gsmtap_sendmsg(target->tgt_gsmtap.gsmtap_inst, msg);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I51431ae7baca33ce5bab085cc3efe25f1a10b6d1
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list