From d47727c032668a79a87a71cd5a66ebdd42060e2f Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Wed, 9 Apr 2014 13:51:41 +0100 Subject: [PATCH] mpegtsmux: guard against _dispose being called mutiple times _dispose calls _reset, so we need to make sure _reset handles already NULLed fields. Coverity 1139843 --- gst/mpegtsmux/mpegtsmux.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/gst/mpegtsmux/mpegtsmux.c b/gst/mpegtsmux/mpegtsmux.c index 23be26d0bb..ffa1c5579c 100644 --- a/gst/mpegtsmux/mpegtsmux.c +++ b/gst/mpegtsmux/mpegtsmux.c @@ -388,8 +388,10 @@ mpegtsmux_reset (MpegTsMux * mux, gboolean alloc) mux->element_index = NULL; } #endif - gst_adapter_clear (mux->adapter); - gst_adapter_clear (mux->out_adapter); + if (mux->adapter) + gst_adapter_clear (mux->adapter); + if (mux->out_adapter) + gst_adapter_clear (mux->out_adapter); if (mux->tsmux) { tsmux_free (mux->tsmux); @@ -414,10 +416,12 @@ mpegtsmux_reset (MpegTsMux * mux, gboolean alloc) gst_event_replace (&mux->force_key_unit_event, NULL); gst_buffer_replace (&mux->out_buffer, NULL); - GST_COLLECT_PADS_STREAM_LOCK (mux->collect); - for (walk = mux->collect->data; walk != NULL; walk = g_slist_next (walk)) - mpegtsmux_pad_reset ((MpegTsPadData *) walk->data); - GST_COLLECT_PADS_STREAM_UNLOCK (mux->collect); + if (mux->collect) { + GST_COLLECT_PADS_STREAM_LOCK (mux->collect); + for (walk = mux->collect->data; walk != NULL; walk = g_slist_next (walk)) + mpegtsmux_pad_reset ((MpegTsPadData *) walk->data); + GST_COLLECT_PADS_STREAM_UNLOCK (mux->collect); + } if (alloc) { mux->tsmux = tsmux_new ();