mpdparser: Fix some memory leaks in the MPD parser and unit test

This commit is contained in:
Sebastian Dröge 2015-07-08 23:14:13 +03:00
parent d525d9c391
commit cd47556351
2 changed files with 10 additions and 6 deletions

View file

@ -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;

View file

@ -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);
}