appsrc: Don't leak buffer list while wrongly unreffing buffer on EOS/flushing
authorSebastian Dröge <sebastian@centricular.com>
Sun, 2 May 2021 17:45:01 +0000 (20:45 +0300)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 3 May 2021 05:42:07 +0000 (05:42 +0000)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1134>

gst-libs/gst/app/gstappsrc.c

index a6f531d..c2267a0 100644 (file)
@@ -2003,16 +2003,24 @@ gst_app_src_push_internal (GstAppSrc * appsrc, GstBuffer * buffer,
 flushing:
   {
     GST_DEBUG_OBJECT (appsrc, "refuse buffer %p, we are flushing", buffer);
-    if (steal_ref)
-      gst_buffer_unref (buffer);
+    if (steal_ref) {
+      if (buflist)
+        gst_buffer_list_unref (buflist);
+      else
+        gst_buffer_unref (buffer);
+    }
     g_mutex_unlock (&priv->mutex);
     return GST_FLOW_FLUSHING;
   }
 eos:
   {
     GST_DEBUG_OBJECT (appsrc, "refuse buffer %p, we are EOS", buffer);
-    if (steal_ref)
-      gst_buffer_unref (buffer);
+    if (steal_ref) {
+      if (buflist)
+        gst_buffer_list_unref (buflist);
+      else
+        gst_buffer_unref (buffer);
+    }
     g_mutex_unlock (&priv->mutex);
     return GST_FLOW_EOS;
   }