alsa-card: fix null dereference

jack->melem can be null if the jack disappears between probing the card
and the init_jacks() call. I don't know if jacks actually ever disappear
like that (seems unlikely), but this check is in any case needed as long
as init_jacks() has proper handling for the jack disappearing case
(rather than just an assert).

There was a crash report[1] that indicated that card_suspend_changed()
called report_jack_state() with a null melem. I don't know if that was
because the jack actually disappeared, or is there some other bug too.

[1] https://bugs.freedesktop.org/show_bug.cgi?id=104385
This commit is contained in:
Tanu Kaskinen 2018-05-24 20:31:51 +03:00
parent 1e68e9aa10
commit 9e5be0899f

View file

@ -640,7 +640,8 @@ static pa_hook_result_t card_suspend_changed(pa_core *c, pa_card *card, struct u
if (card->suspend_cause == 0) { if (card->suspend_cause == 0) {
/* We were unsuspended, update jack state in case it changed while we were suspended */ /* We were unsuspended, update jack state in case it changed while we were suspended */
PA_HASHMAP_FOREACH(jack, u->jacks, state) { PA_HASHMAP_FOREACH(jack, u->jacks, state) {
report_jack_state(jack->melem, 0); if (jack->melem)
report_jack_state(jack->melem, 0);
} }
} }