From 44d02efee0b2274a53ef3b3b7a3828d7aafa2166 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Louis-Francis=20Ratt=C3=A9-Boulianne?= Date: Fri, 1 Feb 2013 17:27:19 -0500 Subject: [PATCH] mssdemux: fix some memory leaks and use right free function --- ext/smoothstreaming/gstmssdemux.c | 20 +++++++------- ext/smoothstreaming/gstmssmanifest.c | 39 ++++++++++++++-------------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/ext/smoothstreaming/gstmssdemux.c b/ext/smoothstreaming/gstmssdemux.c index 27983b5918..6fc33f49e9 100644 --- a/ext/smoothstreaming/gstmssdemux.c +++ b/ext/smoothstreaming/gstmssdemux.c @@ -157,8 +157,6 @@ gst_mss_demux_class_init (GstMssDemuxClass * klass) gobject_class = (GObjectClass *) klass; gstelement_class = (GstElementClass *) klass; - parent_class = g_type_class_peek_parent (klass); - gobject_class->dispose = gst_mss_demux_dispose; gobject_class->set_property = gst_mss_demux_set_property; gobject_class->get_property = gst_mss_demux_get_property; @@ -437,6 +435,7 @@ gst_mss_demux_push_src_event (GstMssDemux * mssdemux, GstEvent * event) gst_event_ref (event); ret = ret & gst_pad_push_event (stream->pad, event); } + gst_event_unref (event); return ret; } @@ -537,7 +536,7 @@ gst_mss_demux_src_event (GstPad * pad, GstEvent * event) &stop_type, &stop); if (format != GST_FORMAT_TIME) - return FALSE; + goto not_supported; GST_DEBUG_OBJECT (mssdemux, "seek event, rate: %f start: %" GST_TIME_FORMAT " stop: %" @@ -549,14 +548,13 @@ gst_mss_demux_src_event (GstPad * pad, GstEvent * event) gst_event_set_seqnum (flush, gst_event_get_seqnum (event)); gst_mss_demux_push_src_event (mssdemux, flush); - gst_event_unref (flush); } gst_mss_demux_stop_tasks (mssdemux, TRUE); if (!gst_mss_manifest_seek (mssdemux->manifest, start)) {; GST_WARNING_OBJECT (mssdemux, "Could not find seeked fragment"); - return FALSE; + goto not_supported; } newsegment = @@ -567,7 +565,8 @@ gst_mss_demux_src_event (GstPad * pad, GstEvent * event) stream->eos = FALSE; gst_data_queue_flush (stream->dataqueue); - stream->pending_newsegment = gst_event_ref (newsegment); + gst_event_ref (newsegment); + gst_event_replace (&stream->pending_newsegment, newsegment); } gst_event_unref (newsegment); @@ -577,11 +576,11 @@ gst_mss_demux_src_event (GstPad * pad, GstEvent * event) gst_event_set_seqnum (flush, gst_event_get_seqnum (event)); gst_mss_demux_push_src_event (mssdemux, flush); - gst_event_unref (flush); } gst_mss_demux_restart_tasks (mssdemux); + gst_event_unref (event); return TRUE; } default: @@ -589,6 +588,10 @@ gst_mss_demux_src_event (GstPad * pad, GstEvent * event) } return gst_pad_event_default (pad, event); + +not_supported: + gst_event_unref (event); + return FALSE; } static gboolean @@ -986,8 +989,7 @@ gst_mss_demux_stream_store_object (GstMssDemuxStream * stream, if (!gst_data_queue_push (stream->dataqueue, item)) { GST_DEBUG_OBJECT (stream->parent, "Failed to store object %p", obj); - gst_mini_object_unref (obj); - g_slice_free (GstDataQueueItem, item); + item->destroy (item); } } diff --git a/ext/smoothstreaming/gstmssmanifest.c b/ext/smoothstreaming/gstmssmanifest.c index 80133f67aa..b1276cf86a 100644 --- a/ext/smoothstreaming/gstmssmanifest.c +++ b/ext/smoothstreaming/gstmssmanifest.c @@ -117,7 +117,7 @@ gst_mss_stream_quality_free (GstMssStreamQuality * quality) { g_return_if_fail (quality != NULL); - g_free (quality->bitrate_str); + xmlFree (quality->bitrate_str); g_slice_free (GstMssStreamQuality, quality); } @@ -160,7 +160,7 @@ _gst_mss_stream_init (GstMssStream * stream, xmlNodePtr node) /* use the node's seq number or use the previous + 1 */ if (seqnum_str) { fragment->number = g_ascii_strtoull (seqnum_str, NULL, 10); - g_free (seqnum_str); + xmlFree (seqnum_str); fragment_number = fragment->number; } else { fragment->number = fragment_number; @@ -170,7 +170,7 @@ _gst_mss_stream_init (GstMssStream * stream, xmlNodePtr node) if (time_str) { fragment->time = g_ascii_strtoull (time_str, NULL, 10); - g_free (time_str); + xmlFree (time_str); fragment_time_accum = fragment->time; } else { fragment->time = fragment_time_accum; @@ -185,7 +185,7 @@ _gst_mss_stream_init (GstMssStream * stream, xmlNodePtr node) previous_fragment = NULL; fragment_time_accum += fragment->duration; - g_free (duration_str); + xmlFree (duration_str); } else { /* store to set the duration at the next iteration */ previous_fragment = fragment; @@ -232,6 +232,7 @@ gst_mss_manifest_new (const GstBuffer * data) if (live_str) { TO_LOWER (live_str); manifest->is_live = strcmp (live_str, "true") == 0; + xmlFree (live_str); } for (nodeiter = root->children; nodeiter; nodeiter = nodeiter->next) { @@ -253,7 +254,7 @@ gst_mss_stream_free (GstMssStream * stream) g_list_free_full (stream->fragments, g_free); g_list_free_full (stream->qualities, (GDestroyNotify) gst_mss_stream_quality_free); - g_free (stream->url); + xmlFree (stream->url); g_regex_unref (stream->regex_position); g_regex_unref (stream->regex_bitrate); g_free (stream); @@ -468,10 +469,10 @@ _gst_mss_stream_video_caps_from_qualitylevel_xml (xmlNodePtr node) } end: - g_free (fourcc); - g_free (max_width); - g_free (max_height); - g_free (codec_data); + xmlFree (fourcc); + xmlFree (max_width); + xmlFree (max_height); + xmlFree (codec_data); return caps; } @@ -566,10 +567,10 @@ _gst_mss_stream_audio_caps_from_qualitylevel_xml (xmlNodePtr node) } end: - g_free (fourcc); - g_free (channels); - g_free (rate); - g_free (codec_data); + xmlFree (fourcc); + xmlFree (channels); + xmlFree (rate); + xmlFree (codec_data); return caps; } @@ -596,7 +597,7 @@ gst_mss_stream_get_timescale (GstMssStream * stream) if (timescale) { ts = strtoull (timescale, NULL, 10); - g_free (timescale); + xmlFree (timescale); } return ts; } @@ -612,7 +613,7 @@ gst_mss_manifest_get_timescale (GstMssManifest * manifest) (xmlChar *) MSS_PROP_TIMESCALE); if (timescale) { ts = strtoull (timescale, NULL, 10); - g_free (timescale); + xmlFree (timescale); } return ts; } @@ -628,7 +629,7 @@ gst_mss_manifest_get_duration (GstMssManifest * manifest) (xmlChar *) MSS_PROP_STREAM_DURATION); if (duration) { dur = strtoull (duration, NULL, 10); - g_free (duration); + xmlFree (duration); } return dur; } @@ -890,7 +891,7 @@ gst_mss_stream_reload_fragments (GstMssStream * stream, xmlNodePtr streamIndex) /* use the node's seq number or use the previous + 1 */ if (seqnum_str) { fragment->number = g_ascii_strtoull (seqnum_str, NULL, 10); - g_free (seqnum_str); + xmlFree (seqnum_str); } else { fragment->number = fragment_number; } @@ -898,7 +899,7 @@ gst_mss_stream_reload_fragments (GstMssStream * stream, xmlNodePtr streamIndex) if (time_str) { fragment->time = g_ascii_strtoull (time_str, NULL, 10); - g_free (time_str); + xmlFree (time_str); fragment_time_accum = fragment->time; } else { fragment->time = fragment_time_accum; @@ -913,7 +914,7 @@ gst_mss_stream_reload_fragments (GstMssStream * stream, xmlNodePtr streamIndex) previous_fragment = NULL; fragment_time_accum += fragment->duration; - g_free (duration_str); + xmlFree (duration_str); } else { /* store to set the duration at the next iteration */ previous_fragment = fragment; -- 2.34.1