kmssink: fix memory leak on failing allowed caps
authorStéphane Cerveau <scerveau@collabora.com>
Thu, 16 Apr 2020 13:35:44 +0000 (15:35 +0200)
committerStéphane Cerveau <scerveau@collabora.com>
Thu, 16 Apr 2020 14:10:56 +0000 (16:10 +0200)
When drm does not find any format, the allowed_caps is
empty one and need to be unref by the caller.

Fix #1268

sys/kms/gstkmssink.c

index 86d45ce4e615121d096278f5df63083008883fb3..e9e3fe9977e158a2537f7f4ee54fef884c66ff0e 100644 (file)
@@ -568,12 +568,18 @@ ensure_allowed_caps (GstKMSSink * self, drmModeConnector * conn,
     out_caps = gst_caps_merge (out_caps, gst_caps_simplify (tmp_caps));
   }
 
+  if (gst_caps_is_empty (out_caps)) {
+    GST_DEBUG_OBJECT (self, "allowed caps is empty");
+    gst_caps_unref (out_caps);
+    return FALSE;
+  }
+
   self->allowed_caps = gst_caps_simplify (out_caps);
 
   GST_DEBUG_OBJECT (self, "allowed caps = %" GST_PTR_FORMAT,
       self->allowed_caps);
 
-  return (self->allowed_caps && !gst_caps_is_empty (self->allowed_caps));
+  return TRUE;
 }
 
 static gboolean