va: Fix the caps memory leak by gst_va_pool_new_with_config().
authorHe Junyan <junyan.he@intel.com>
Thu, 1 Dec 2022 14:50:30 +0000 (22:50 +0800)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 1 Dec 2022 17:31:16 +0000 (17:31 +0000)
The gst_va_pool_new_with_config() will ref the caps, and so we need
to unref after that.

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

subprojects/gst-plugins-bad/sys/va/gstvaav1dec.c
subprojects/gst-plugins-bad/sys/va/gstvabaseenc.c

index 10f3432..2c1bb79 100644 (file)
@@ -312,10 +312,11 @@ _create_internal_pool (GstVaAV1Dec * self, gint width, gint height)
   pool = gst_va_pool_new_with_config (caps, GST_VIDEO_INFO_SIZE (&info),
       1, 0, VA_SURFACE_ATTRIB_USAGE_HINT_DECODER, GST_VA_FEATURE_AUTO,
       allocator, &params);
+  gst_clear_caps (&caps);
+
   if (!pool) {
     GST_WARNING_OBJECT (self, "Failed to create internal pool");
     gst_object_unref (allocator);
-    gst_clear_caps (&caps);
     return NULL;
   }
 
index be36f06..2cadb5d 100644 (file)
@@ -197,7 +197,7 @@ _get_sinkpad_pool (GstVaBaseEnc * base)
   GstAllocationParams params = { 0, };
   guint size, usage_hint = 0;
   GArray *surface_formats = NULL;
-  GstCaps *caps;
+  GstCaps *caps = NULL;
 
   if (base->priv->raw_pool)
     return base->priv->raw_pool;
@@ -217,6 +217,8 @@ _get_sinkpad_pool (GstVaBaseEnc * base)
 
   base->priv->raw_pool = gst_va_pool_new_with_config (caps, size, 1, 0,
       usage_hint, GST_VA_FEATURE_AUTO, allocator, &params);
+  gst_clear_caps (&caps);
+
   if (!base->priv->raw_pool) {
     gst_object_unref (allocator);
     return NULL;