From 7787f439fca95f5fdf121477493ada8da91fb8a2 Mon Sep 17 00:00:00 2001 From: Havard Graff Date: Fri, 4 Dec 2015 00:46:34 +1100 Subject: flvmux: plug leak(s) in error-scenario https://bugzilla.gnome.org/show_bug.cgi?id=762210 --- gst/flv/gstflvmux.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/gst/flv/gstflvmux.c b/gst/flv/gstflvmux.c index b7c0b5168..30d952679 100644 --- a/gst/flv/gstflvmux.c +++ b/gst/flv/gstflvmux.c @@ -1317,21 +1317,35 @@ gst_flv_mux_write_header (GstFlvMux * mux) /* push the header buffer, the metadata and the codec info, if any */ ret = gst_flv_mux_push (mux, header); if (ret != GST_FLOW_OK) - return ret; + goto failure_header; ret = gst_flv_mux_push (mux, metadata); if (ret != GST_FLOW_OK) - return ret; + goto failure_metadata; if (video_codec_data != NULL) { ret = gst_flv_mux_push (mux, video_codec_data); if (ret != GST_FLOW_OK) - return ret; + goto failure_video_codec_data; } if (audio_codec_data != NULL) { ret = gst_flv_mux_push (mux, audio_codec_data); if (ret != GST_FLOW_OK) - return ret; + goto failure_audio_codec_data; } return GST_FLOW_OK; + +failure_header: + gst_buffer_unref (metadata); + +failure_metadata: + if (video_codec_data != NULL) + gst_buffer_unref (video_codec_data); + +failure_video_codec_data: + if (audio_codec_data != NULL) + gst_buffer_unref (audio_codec_data); + +failure_audio_codec_data: + return ret; } static void @@ -1581,8 +1595,10 @@ gst_flv_mux_handle_buffer (GstCollectPads * pads, GstCollectData * cdata, } ret = gst_flv_mux_write_header (mux); - if (ret != GST_FLOW_OK) - return ret; + if (ret != GST_FLOW_OK) { + gst_buffer_unref (buffer); + return ret; + } mux->state = GST_FLV_MUX_STATE_DATA; if (GST_COLLECT_PADS_DTS_IS_VALID (cdata)) -- cgit v1.2.1