splitmuxsink: Fix some reference leaks in error cases.
authorJan Schmidt <jan@centricular.com>
Mon, 26 Jul 2021 07:55:24 +0000 (17:55 +1000)
committerJan Schmidt <jan@centricular.com>
Mon, 26 Jul 2021 07:56:42 +0000 (17:56 +1000)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/1023>

gst/multifile/gstsplitmuxsink.c

index b040857..0d4a6a3 100644 (file)
@@ -1946,6 +1946,8 @@ start_next_fragment (GstSplitMuxSink * splitmux, MqStreamCtx * ctx)
         "Shutdown requested. Aborting fragment switch.");
     GST_SPLITMUX_LOCK (splitmux);
     GST_SPLITMUX_STATE_UNLOCK (splitmux);
+    gst_object_unref (muxer);
+    gst_object_unref (sink);
     return GST_FLOW_FLUSHING;
   }
 
@@ -2092,6 +2094,9 @@ start_next_fragment (GstSplitMuxSink * splitmux, MqStreamCtx * ctx)
   return GST_FLOW_OK;
 
 fail:
+  gst_object_unref (sink);
+  gst_object_unref (muxer);
+
   GST_SPLITMUX_LOCK (splitmux);
   GST_SPLITMUX_STATE_UNLOCK (splitmux);
   GST_ELEMENT_ERROR (splitmux, RESOURCE, SETTINGS,
@@ -2101,6 +2106,8 @@ fail:
 fail_output:
   GST_ELEMENT_ERROR (splitmux, RESOURCE, SETTINGS,
       ("Could not start new output sink"), NULL);
+  gst_object_unref (sink);
+  gst_object_unref (muxer);
 
   GST_SPLITMUX_LOCK (splitmux);
   GST_SPLITMUX_STATE_UNLOCK (splitmux);
@@ -2110,6 +2117,8 @@ fail_output:
 fail_muxer:
   GST_ELEMENT_ERROR (splitmux, RESOURCE, SETTINGS,
       ("Could not start new muxer"), NULL);
+  gst_object_unref (sink);
+  gst_object_unref (muxer);
 
   GST_SPLITMUX_LOCK (splitmux);
   GST_SPLITMUX_STATE_UNLOCK (splitmux);