From c7e1676dcd1664d2bdf52bc399e3ae90fe2d2494 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 6 Aug 2007 16:09:27 +0200 Subject: [PATCH] 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(). --- src/pcm/pcm_hw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; } -- 2.47.1