pod: also check choice size before cast

Do a more thorough test of the choice type by not only checking the type
but also if the size is at least large enough to be able to cast it to
the pod_choice type and look at the contents.
This commit is contained in:
Wim Taymans 2025-07-22 12:14:06 +02:00
parent ed7398a64a
commit da1d4fb30c
2 changed files with 3 additions and 3 deletions

View file

@ -397,7 +397,7 @@ SPA_API_POD_FILTER int spa_pod_filter_object_make(struct spa_pod_object *pod)
int count = 0;
SPA_POD_OBJECT_FOREACH(pod, res) {
if (res->value.type == SPA_TYPE_Choice &&
if (spa_pod_is_choice(res->value) &&
!SPA_FLAG_IS_SET(res->flags, SPA_POD_PROP_FLAG_DONT_FIXATE)) {
uint32_t nvals, choice;
struct spa_pod *v = spa_pod_get_values(&res->value, &nvals, &choice);

View file

@ -451,7 +451,7 @@ SPA_API_POD_ITER int spa_pod_object_fixate(struct spa_pod_object *pod)
{
struct spa_pod_prop *res;
SPA_POD_OBJECT_FOREACH(pod, res) {
if (res->value.type == SPA_TYPE_Choice &&
if (spa_pod_is_choice(&res->value) &&
!SPA_FLAG_IS_SET(res->flags, SPA_POD_PROP_FLAG_DONT_FIXATE))
((struct spa_pod_choice*)&res->value)->body.type = SPA_CHOICE_None;
}
@ -461,7 +461,7 @@ SPA_API_POD_ITER int spa_pod_object_is_fixated(const struct spa_pod_object *pod)
{
struct spa_pod_prop *res;
SPA_POD_OBJECT_FOREACH(pod, res) {
if (res->value.type == SPA_TYPE_Choice &&
if (spa_pod_is_choice(&res->value) &&
((struct spa_pod_choice*)&res->value)->body.type != SPA_CHOICE_None)
return 0;
}