videoscale: Fix test for allowed caps

videoscale_get_allowed_caps_for_method() could leave holes in the
returned array, causing the test to skip some caps and not free them.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9151>
This commit is contained in:
Doug Nazar 2025-05-30 15:11:31 -04:00 committed by GStreamer Marge Bot
parent 3c8cb96826
commit 03f465a6de

View File

@ -167,7 +167,7 @@ videoscale_get_allowed_caps_for_method (int method)
GstCaps *caps, **ret;
GstPad *pad;
GstStructure *s;
gint i, n;
gint i, j, n;
scale = gst_element_factory_make ("videoscale", "vscale");
g_object_set (scale, "method", method, NULL);
@ -180,14 +180,16 @@ videoscale_get_allowed_caps_for_method (int method)
n = gst_caps_get_size (caps);
ret = g_new0 (GstCaps *, n + 1);
for (i = 0; i < n; i++) {
for (i = 0, j = 0; i < n; i++) {
/* Skip passthrough caps */
if (gst_caps_features_is_any (gst_caps_get_features (caps, i)))
continue;
s = gst_caps_get_structure (caps, i);
ret[i] = gst_caps_new_empty ();
gst_caps_append_structure (ret[i], gst_structure_copy (s));
ret[j] = gst_caps_new_empty ();
gst_caps_append_structure (ret[j], gst_structure_copy (s));
GST_LOG ("method %d supports: %" GST_PTR_FORMAT, method, s);
j++;
}
gst_caps_unref (caps);