[v5,1/7] switch-on-port-available: Fix null pointer dereference

Submitted by Pali Rohár on Jan. 19, 2019, 5:11 p.m.

Details

Message ID 20190119171156.15810-2-pali.rohar@gmail.com
State Superseded
Headers show
Series "New API for Bluetooth A2DP codecs" ( rev: 15 14 13 12 11 10 9 ) in PulseAudio

Not browsing as part of any series.

Commit Message

Pali Rohár Jan. 19, 2019, 5:11 p.m.
Sometimes on pulseaudio startup card->active_profile is NULL.
---
 src/modules/module-switch-on-port-available.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/src/modules/module-switch-on-port-available.c b/src/modules/module-switch-on-port-available.c
index 2fa7e4d62..9f344d0dc 100644
--- a/src/modules/module-switch-on-port-available.c
+++ b/src/modules/module-switch-on-port-available.c
@@ -343,7 +343,7 @@  static pa_hook_result_t card_profile_available_hook_callback(pa_core *c, pa_card
     if (profile->available != PA_AVAILABLE_NO)
         return PA_HOOK_OK;
 
-    if (!pa_streq(profile->name, card->active_profile->name))
+    if (!card->active_profile || !pa_streq(profile->name, card->active_profile->name))
         return PA_HOOK_OK;
 
     pa_log_debug("Active profile %s on card %s became unavailable, switching to another profile", profile->name, card->name);

Comments

On 19.01.19 18:11, Pali Rohár wrote:
> Sometimes on pulseaudio startup card->active_profile is NULL.
> ---
>   src/modules/module-switch-on-port-available.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/modules/module-switch-on-port-available.c b/src/modules/module-switch-on-port-available.c
> index 2fa7e4d62..9f344d0dc 100644
> --- a/src/modules/module-switch-on-port-available.c
> +++ b/src/modules/module-switch-on-port-available.c
> @@ -343,7 +343,7 @@ static pa_hook_result_t card_profile_available_hook_callback(pa_core *c, pa_card
>       if (profile->available != PA_AVAILABLE_NO)
>           return PA_HOOK_OK;
>   
> -    if (!pa_streq(profile->name, card->active_profile->name))
> +    if (!card->active_profile || !pa_streq(profile->name, card->active_profile->name))
>           return PA_HOOK_OK;
>   
>       pa_log_debug("Active profile %s on card %s became unavailable, switching to another profile", profile->name, card->name);

I think this one has already been fixed differently - see merge request 
38 on GitLab.