[MERGED] 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
Sat Feb 17 13:09:30 UTC 2018


Neels Hofmeyr has submitted this change and it was merged.

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


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(-)

Approvals:
  Vadim Yanitskiy: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



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: merged
Gerrit-Change-Id: I51431ae7baca33ce5bab085cc3efe25f1a10b6d1
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>



More information about the gerrit-log mailing list