alsa-pcm: check if bound ctls are valid before using it.

When bound_ctl info cannot be read this array elem info
is set to NULL in 'fetch_bind_ctl'. So when we iterate
the bound_ctl array we always have to check this.
This commit is contained in:
Stefan Ursella 2024-06-07 06:19:00 +00:00 committed by Wim Taymans
parent 45758ecb68
commit 898f854ca7

View file

@ -489,6 +489,10 @@ static void add_bind_ctl_params(struct state *state, struct spa_pod_builder *b)
int err;
for (unsigned int i = 0; i < state->num_bind_ctls; i++) {
if(!state->bound_ctls[i].value || !state->bound_ctls[i].info)
continue;
err = snd_ctl_elem_read(state->ctl, state->bound_ctls[i].value);
if (err < 0) {
spa_log_warn(state->log, "Could not read elem value for '%s': %s",
@ -699,6 +703,9 @@ static void bind_ctl_event(struct spa_source *source)
for (unsigned int i = 0; i < state->num_bind_ctls; i++) {
int err;
if(!state->bound_ctls[i].value || !state->bound_ctls[i].info)
continue;
// Check if we have the right element
snd_ctl_elem_value_get_id(state->bound_ctls[i].value, bound_id);
if (snd_ctl_elem_id_compare_set(id, bound_id) ||