From 03f1dfcf99e043f7d48b0712067102dbf6867f40 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 17 Aug 2020 11:33:17 +0200 Subject: [PATCH] acp: handle unset profile The active profile is set to -1 initially, don't try to do anything with the profile if it is invalid. See rhbz#1868332 --- spa/plugins/alsa/alsa-acp-device.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/spa/plugins/alsa/alsa-acp-device.c b/spa/plugins/alsa/alsa-acp-device.c index 20cf7ce6d..a76c8d3a7 100644 --- a/spa/plugins/alsa/alsa-acp-device.c +++ b/spa/plugins/alsa/alsa-acp-device.c @@ -231,15 +231,20 @@ static int impl_add_listener(void *object, spa_return_val_if_fail(events != NULL, -EINVAL); card = this->card; - profile = card->profiles[card->active_profile_index]; + if (card->active_profile_index < card->n_profiles) + profile = card->profiles[card->active_profile_index]; + else + profile = NULL; spa_hook_list_isolate(&this->hooks, &save, listener, events, data); if (events->info || events->object_info) emit_info(this, true); - for (i = 0; i < profile->n_devices; i++) - emit_node(this, profile->devices[i]); + if (profile) { + for (i = 0; i < profile->n_devices; i++) + emit_node(this, profile->devices[i]); + } spa_hook_list_join(&this->hooks, &save); @@ -441,7 +446,7 @@ static int impl_enum_params(void *object, int seq, break; case SPA_PARAM_Profile: - if (result.index > 0) + if (result.index > 0 || card->active_profile_index >= card->n_profiles) return 0; pr = card->profiles[card->active_profile_index];