tsmux: Don't leak buffer in error cases

https://bugzilla.gnome.org/show_bug.cgi?id=757049
This commit is contained in:
Sebastian Dröge 2015-10-25 19:31:51 +02:00
parent 4e803d0bb3
commit 23a9e4323a

View file

@ -1117,8 +1117,11 @@ mpegtsmux_collected_buffer (GstCollectPads * pads, GstCollectData * data,
if (G_UNLIKELY (mux->first)) { if (G_UNLIKELY (mux->first)) {
ret = mpegtsmux_create_streams (mux); 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; return ret;
}
mpegtsmux_prepare_srcpad (mux); mpegtsmux_prepare_srcpad (mux);
@ -1133,6 +1136,9 @@ mpegtsmux_collected_buffer (GstCollectPads * pads, GstCollectData * data,
mpegtsmux_push_packets (mux, TRUE); mpegtsmux_push_packets (mux, TRUE);
gst_pad_push_event (mux->srcpad, gst_event_new_eos ()); gst_pad_push_event (mux->srcpad, gst_event_new_eos ());
if (buf)
gst_buffer_unref (buf);
return GST_FLOW_OK; 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)) { 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"); GST_WARNING_OBJECT (mux, "KLV meta unit too big, splitting not supported");
if (buf)
gst_buffer_unref (buf);
return GST_FLOW_OK; return GST_FLOW_OK;
} }
@ -1273,6 +1281,8 @@ write_fail:
} }
no_program: no_program:
{ {
if (buf)
gst_buffer_unref (buf);
GST_ELEMENT_ERROR (mux, STREAM, MUX, GST_ELEMENT_ERROR (mux, STREAM, MUX,
("Stream on pad %" GST_PTR_FORMAT ("Stream on pad %" GST_PTR_FORMAT
" is not associated with any program", COLLECT_DATA_PAD (best)), " is not associated with any program", COLLECT_DATA_PAD (best)),