From 898f854ca73493df87a4c57b6605fd5e858a251e Mon Sep 17 00:00:00 2001 From: Stefan Ursella Date: Fri, 7 Jun 2024 06:19:00 +0000 Subject: [PATCH] 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. --- spa/plugins/alsa/alsa-pcm.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c index 0d2c7c7bf..4201f19dd 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -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) ||