Fix segfault in aplay when snd_pcm_name() == NULL

Fix segfault in aplay when snd_pcm_name() == NULL.
This commit is contained in:
Takashi Iwai 2006-08-03 17:27:35 +02:00
parent e45ba7e644
commit 2759c90a67

View file

@ -918,8 +918,9 @@ static void set_params(void)
if ((float)rate * 1.05 < hwparams.rate || (float)rate * 0.95 > hwparams.rate) {
if (!quiet_mode) {
char plugex[64];
const char *pcmname = snd_pcm_name(handle);
fprintf(stderr, _("Warning: rate is not accurate (requested = %iHz, got = %iHz)\n"), rate, hwparams.rate);
if (strchr(snd_pcm_name(handle), ':'))
if (! pcmname || strchr(snd_pcm_name(handle), ':'))
*plugex = 0;
else
snprintf(plugex, sizeof(plugex), "(-Dplug:%s)",