Submitted By: Xi Ruoyao Date: 2024-04-10 Initial Package Version: 1.0.4 Upstream Status: Applied Origin: Upstream Description: Fixes a regression breaking Snapshot From b5284791fc414b2355bbb738a49bd8193a14c447 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 10 Apr 2024 11:06:44 +0200 Subject: [PATCH] v4l2: handle empty properties gracefully When a property is not found or is empty, go on to the next format instead of failing. See #3959 --- spa/plugins/v4l2/v4l2-utils.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/spa/plugins/v4l2/v4l2-utils.c b/spa/plugins/v4l2/v4l2-utils.c index ab9d3aec9..4c583355c 100644 --- a/spa/plugins/v4l2/v4l2-utils.c +++ b/spa/plugins/v4l2/v4l2-utils.c @@ -386,9 +386,8 @@ enum_filter_format(uint32_t media_type, int32_t media_subtype, return -ENOENT; val = spa_pod_get_values(&p->value, &n_values, &choice); - - if (val->type != SPA_TYPE_Id) - return -EINVAL; + if (val->type != SPA_TYPE_Id || n_values == 0) + return SPA_VIDEO_FORMAT_UNKNOWN; values = SPA_POD_BODY(val); @@ -614,7 +613,7 @@ do_enum_fmt: goto do_frmsize; val = spa_pod_get_values(&p->value, &n_vals, &choice); - if (val->type != SPA_TYPE_Rectangle) + if (val->type != SPA_TYPE_Rectangle || n_vals == 0) goto enum_end; if (choice == SPA_CHOICE_None) { @@ -652,7 +651,7 @@ do_enum_fmt: goto have_size; val = spa_pod_get_values(&p->value, &n_values, &choice); - if (val->type != SPA_TYPE_Rectangle) + if (val->type != SPA_TYPE_Rectangle || n_values == 0) goto have_size; values = SPA_POD_BODY_CONST(val); @@ -772,8 +771,7 @@ do_enum_fmt: goto have_framerate; val = spa_pod_get_values(&p->value, &n_values, &choice); - - if (val->type != SPA_TYPE_Fraction) + if (val->type != SPA_TYPE_Fraction || n_values == 0) goto enum_end; values = SPA_POD_BODY(val); -- GitLab