Change in osmo-mgw[master]: conn: call talloc_free before setting the pointer to NULL

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

dexter gerrit-no-reply at lists.osmocom.org
Mon Jun 4 07:46:49 UTC 2018


dexter has uploaded this change for review. ( https://gerrit.osmocom.org/9441


Change subject: conn: call talloc_free before setting the pointer to NULL
......................................................................

conn: call talloc_free before setting the pointer to NULL

in mgcp_rtp_codec_init() tallo_free is called after codec->subtype_name
and codec->audio_name are set to NULL. So talloc_free() always sees
NULL-pointers and never frees anything. This may cause a memory leak.

- call talloc_free() first, then set pointers to NULL

Change-Id: I7373819c3689d34811846f6f48f27568297b26e4
---
M src/libosmo-mgcp/mgcp_conn.c
1 file changed, 4 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/41/9441/1

diff --git a/src/libosmo-mgcp/mgcp_conn.c b/src/libosmo-mgcp/mgcp_conn.c
index a7cd6cf..4926768 100644
--- a/src/libosmo-mgcp/mgcp_conn.c
+++ b/src/libosmo-mgcp/mgcp_conn.c
@@ -91,6 +91,10 @@
 /* Reset codec state and free memory */
 static void mgcp_rtp_codec_init(struct mgcp_rtp_codec *codec)
 {
+	/* see also mgcp_sdp.c, mgcp_set_audio_info() */
+	talloc_free(codec->subtype_name);
+	talloc_free(codec->audio_name);
+
 	codec->payload_type = -1;
 	codec->subtype_name = NULL;
 	codec->audio_name = NULL;
@@ -98,10 +102,6 @@
 	codec->frame_duration_den = DEFAULT_RTP_AUDIO_FRAME_DUR_DEN;
 	codec->rate = DEFAULT_RTP_AUDIO_DEFAULT_RATE;
 	codec->channels = DEFAULT_RTP_AUDIO_DEFAULT_CHANNELS;
-
-	/* see also mgcp_sdp.c, mgcp_set_audio_info() */
-	talloc_free(codec->subtype_name);
-	talloc_free(codec->audio_name);
 }
 
 /* Initialize rtp connection struct with default values */

-- 
To view, visit https://gerrit.osmocom.org/9441
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7373819c3689d34811846f6f48f27568297b26e4
Gerrit-Change-Number: 9441
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180604/a31edb79/attachment.htm>


More information about the gerrit-log mailing list