Don't set PCM pointer at error in snd_pcm_hw_open()

snd_pcm_hw_open() may set a non-NULL to pcmp even if it returns an error.
Some codes like dmix expects it's NULL, and cause the double free().
This commit is contained in:
Takashi Iwai 2007-08-06 16:09:27 +02:00
parent fca29a6172
commit c7e1676dcd

View file

@ -1015,8 +1015,6 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name,
pcm->poll_fd = fd;
pcm->poll_events = info.stream == SND_PCM_STREAM_PLAYBACK ? POLLOUT : POLLIN;
*pcmp = pcm;
ret = snd_pcm_hw_mmap_status(pcm);
if (ret < 0) {
snd_pcm_close(pcm);
@ -1027,6 +1025,8 @@ int snd_pcm_hw_open_fd(snd_pcm_t **pcmp, const char *name,
snd_pcm_close(pcm);
return ret;
}
*pcmp = pcm;
return 0;
}