From cd4755635111775ed2df1616e0410664b4869f81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 8 Jul 2015 23:14:13 +0300 Subject: mpdparser: Fix some memory leaks in the MPD parser and unit test --- ext/dash/gstmpdparser.c | 12 ++++++------ tests/check/elements/dash_mpd.c | 4 ++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ext/dash/gstmpdparser.c b/ext/dash/gstmpdparser.c index 879ef6bd2..c46240f30 100644 --- a/ext/dash/gstmpdparser.c +++ b/ext/dash/gstmpdparser.c @@ -3832,7 +3832,7 @@ gst_mpd_client_get_next_fragment (GstMpdClient * client, mediaURL = g_strdup (gst_mpdparser_get_mediaURL (stream, currentChunk->SegmentURL)); - indexURL = currentChunk->SegmentURL->index; + indexURL = g_strdup (currentChunk->SegmentURL->index); } else if (stream->cur_seg_template != NULL) { mediaURL = gst_mpdparser_build_URL_from_template (stream-> @@ -3905,6 +3905,7 @@ gst_mpd_client_get_next_fragment (GstMpdClient * client, base_url = gst_uri_from_string (stream->baseURL); frag_url = gst_uri_from_string_with_base (base_url, mediaURL); + g_free (mediaURL); if (stream->queryURL) { frag_url = gst_uri_make_writable (frag_url); gst_uri_set_query_string (frag_url, stream->queryURL); @@ -3918,11 +3919,8 @@ gst_mpd_client_get_next_fragment (GstMpdClient * client, gst_uri_set_query_string (frag_url, stream->queryURL); fragment->index_uri = gst_uri_to_string (frag_url); gst_uri_unref (frag_url); - } - - gst_uri_unref (base_url); - - if (indexURL == NULL && (fragment->index_range_start + g_free (indexURL); + } else if (indexURL == NULL && (fragment->index_range_start || fragment->index_range_end != -1)) { /* index has no specific URL but has a range, we should only use this if * the media also has a range, otherwise we are serving some data twice @@ -3936,6 +3934,8 @@ gst_mpd_client_get_next_fragment (GstMpdClient * client, } } + gst_uri_unref (base_url); + GST_DEBUG ("Loading chunk with URL %s", fragment->uri); return TRUE; diff --git a/tests/check/elements/dash_mpd.c b/tests/check/elements/dash_mpd.c index e17d72ac9..d036994a0 100644 --- a/tests/check/elements/dash_mpd.c +++ b/tests/check/elements/dash_mpd.c @@ -2914,6 +2914,8 @@ GST_START_TEST (dash_mpdparser_get_audio_languages) assert_equals_string ((gchar *) g_list_nth_data (languages, 0), "en"); assert_equals_string ((gchar *) g_list_nth_data (languages, 1), "fr"); + g_list_free (languages); + gst_mpd_client_free (mpdclient); } @@ -3266,6 +3268,7 @@ GST_START_TEST (dash_mpdparser_headers) assert_equals_string (uri, "TestSourceUrl"); assert_equals_int64 (range_start, 100); assert_equals_int64 (range_end, 200); + g_free (uri); /* get segment url and range from segment indexRange */ ret = @@ -3275,6 +3278,7 @@ GST_START_TEST (dash_mpdparser_headers) assert_equals_string (uri, "TestSourceUrl"); assert_equals_int64 (range_start, 10); assert_equals_int64 (range_end, 20); + g_free (uri); gst_mpd_client_free (mpdclient); } -- cgit v1.2.1