*: more type checks for POD

Check that POD is correctly typed before using it.
This commit is contained in:
Demi Marie Obenour 2025-07-24 19:33:38 -04:00
parent a50b66651e
commit c64a34d93f
20 changed files with 67 additions and 28 deletions

View file

@ -42,6 +42,7 @@ spa_format_audio_dsd_parse(const struct spa_pod *format, struct spa_audio_info_d
SPA_FORMAT_AUDIO_channels, SPA_POD_OPT_Int(&info->channels),
SPA_FORMAT_AUDIO_position, SPA_POD_OPT_Pod(&position));
if (position == NULL ||
!spa_pod_is_array(position) ||
!spa_pod_copy_array(position, SPA_TYPE_Id, info->position, SPA_AUDIO_MAX_CHANNELS))
SPA_FLAG_SET(info->flags, SPA_AUDIO_FLAG_UNPOSITIONED);

View file

@ -41,6 +41,7 @@ spa_format_audio_raw_parse(const struct spa_pod *format, struct spa_audio_info_r
SPA_FORMAT_AUDIO_channels, SPA_POD_OPT_Int(&info->channels),
SPA_FORMAT_AUDIO_position, SPA_POD_OPT_Pod(&position));
if (position == NULL ||
!spa_pod_is_array(position) ||
!spa_pod_copy_array(position, SPA_TYPE_Id, info->position, SPA_AUDIO_MAX_CHANNELS))
SPA_FLAG_SET(info->flags, SPA_AUDIO_FLAG_UNPOSITIONED);

View file

@ -31,8 +31,10 @@ SPA_API_VIDEO_DSP_UTILS int
spa_format_video_dsp_parse(const struct spa_pod *format,
struct spa_video_info_dsp *info)
{
info->flags = SPA_VIDEO_FLAG_NONE;
const struct spa_pod_prop *mod_prop;
info->flags = SPA_VIDEO_FLAG_NONE;
if (!spa_pod_is_object_type(format, SPA_TYPE_OBJECT_Format))
return -EINVAL;
if ((mod_prop = spa_pod_find_prop (format, NULL, SPA_FORMAT_VIDEO_modifier)) != NULL) {
info->flags |= SPA_VIDEO_FLAG_MODIFIER;
if ((mod_prop->flags & SPA_POD_PROP_FLAG_DONT_FIXATE) == SPA_POD_PROP_FLAG_DONT_FIXATE)

View file

@ -33,6 +33,8 @@ spa_format_video_raw_parse(const struct spa_pod *format,
{
info->flags = SPA_VIDEO_FLAG_NONE;
const struct spa_pod_prop *mod_prop;
if (!spa_pod_is_object_type(format, SPA_TYPE_OBJECT_Format))
return -EINVAL;
if ((mod_prop = spa_pod_find_prop (format, NULL, SPA_FORMAT_VIDEO_modifier)) != NULL) {
info->flags |= SPA_VIDEO_FLAG_MODIFIER;
if ((mod_prop->flags & SPA_POD_PROP_FLAG_DONT_FIXATE) == SPA_POD_PROP_FLAG_DONT_FIXATE)