From 23a9e4323aa0bb86b5b50f80d6f896ff2071d990 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 25 Oct 2015 19:31:51 +0200 Subject: [PATCH] tsmux: Don't leak buffer in error cases https://bugzilla.gnome.org/show_bug.cgi?id=757049 --- gst/mpegtsmux/mpegtsmux.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gst/mpegtsmux/mpegtsmux.c b/gst/mpegtsmux/mpegtsmux.c index bb918bcc0f..9b7abfc87e 100644 --- a/gst/mpegtsmux/mpegtsmux.c +++ b/gst/mpegtsmux/mpegtsmux.c @@ -1117,8 +1117,11 @@ mpegtsmux_collected_buffer (GstCollectPads * pads, GstCollectData * data, if (G_UNLIKELY (mux->first)) { ret = mpegtsmux_create_streams (mux); - if (G_UNLIKELY (ret != GST_FLOW_OK)) + if (G_UNLIKELY (ret != GST_FLOW_OK)) { + if (buf) + gst_buffer_unref (buf); return ret; + } mpegtsmux_prepare_srcpad (mux); @@ -1133,6 +1136,9 @@ mpegtsmux_collected_buffer (GstCollectPads * pads, GstCollectData * data, mpegtsmux_push_packets (mux, TRUE); gst_pad_push_event (mux->srcpad, gst_event_new_eos ()); + if (buf) + gst_buffer_unref (buf); + return GST_FLOW_OK; } @@ -1234,6 +1240,8 @@ mpegtsmux_collected_buffer (GstCollectPads * pads, GstCollectData * data, if (best->stream->is_meta && gst_buffer_get_size (buf) > (G_MAXUINT16 - 3)) { GST_WARNING_OBJECT (mux, "KLV meta unit too big, splitting not supported"); + if (buf) + gst_buffer_unref (buf); return GST_FLOW_OK; } @@ -1273,6 +1281,8 @@ write_fail: } no_program: { + if (buf) + gst_buffer_unref (buf); GST_ELEMENT_ERROR (mux, STREAM, MUX, ("Stream on pad %" GST_PTR_FORMAT " is not associated with any program", COLLECT_DATA_PAD (best)),