mfvideosrc: Fix buffer leak
authorSeungha Yang <seungha@centricular.com>
Mon, 28 Nov 2022 17:22:50 +0000 (02:22 +0900)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 28 Nov 2022 18:50:03 +0000 (18:50 +0000)
The allocated buffer should be released

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3479>

subprojects/gst-plugins-bad/sys/mediafoundation/gstmfvideosrc.cpp

index d909d07..81ae8f0 100644 (file)
@@ -451,16 +451,20 @@ gst_mf_video_src_create (GstPushSrc * pushsrc, GstBuffer ** buffer)
     ret = GST_BASE_SRC_CLASS (parent_class)->alloc (GST_BASE_SRC (self), 0,
         GST_VIDEO_INFO_SIZE (&self->info), &buf);
 
-    if (ret != GST_FLOW_OK)
+    if (ret != GST_FLOW_OK) {
+      gst_clear_buffer (&buf);
       return ret;
+    }
 
     ret = gst_mf_source_object_fill (self->source, buf);
   } else {
     ret = gst_mf_source_object_create (self->source, &buf);
   }
 
-  if (ret != GST_FLOW_OK)
+  if (ret != GST_FLOW_OK) {
+    gst_clear_buffer (&buf);
     return ret;
+  }
 
   /* DirectShow capture object will set caps if it's got updated */
   if (sample) {