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