libs: encoder: unref formats array if none
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Fri, 17 Jan 2020 11:54:21 +0000 (12:54 +0100)
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Sun, 19 Jan 2020 10:37:02 +0000 (10:37 +0000)
The formats array is always created, in order to keep the logic and
to avoid broken caps, if this formats array doesn't contain any
elements, it has to be unref and the function should return NULL.

gst-libs/gst/vaapi/gstvaapiencoder.c

index 771a82b..edc443a 100644 (file)
@@ -1577,8 +1577,10 @@ gst_vaapi_encoder_get_surface_attributes (GstVaapiEncoder * encoder,
     }
   }
 
-  if (!attribs.formats)
+  if (attribs.formats->len == 0) {
+    g_array_unref (attribs.formats);
     return NULL;
+  }
 
   if (min_width)
     *min_width = attribs.min_width;