From: Takashi Iwai Date: Mon, 6 Aug 2007 14:09:27 +0000 (+0200) Subject: Don't set PCM pointer at error in snd_pcm_hw_open() X-Git-Tag: v1.0.15rc1~14 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=c7e1676dcd1664d2bdf52bc399e3ae90fe2d2494;p=alsa-lib.git 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(). --- diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c index aa69e30a..6ac66aa4 100644 --- a/src/pcm/pcm_hw.c +++ b/src/pcm/pcm_hw.c @@ -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; }