alsactl: Fix potential NULL dereferences in daemon mode

The code releasing the each card object may access to NULL when a
bogus count is given.  Add a NULL check just to make sure.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Takashi Iwai 2016-12-09 17:28:47 +01:00
parent 9ea2a1d067
commit 9839813e7c

View file

@ -451,8 +451,10 @@ save:
out: out:
free(pfd); free(pfd);
remove(pidfile); remove(pidfile);
for (i = 0; i < count; i++) if (cards) {
card_free(&cards[i]); for (i = 0; i < count; i++)
free(cards); card_free(&cards[i]);
free(cards);
}
return 0; return 0;
} }