]> git.alsa-project.org Git - alsa-lib.git/commitdiff
Don't set PCM pointer at error in snd_pcm_hw_open()
authorTakashi Iwai <tiwai@suse.de>
Mon, 6 Aug 2007 14:09:27 +0000 (16:09 +0200)
committerTakashi Iwai <tiwai@suse.de>
Mon, 6 Aug 2007 14:09:27 +0000 (16:09 +0200)
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

index aa69e30af23fe246eb8d82d2223cd572f618387b..6ac66aa417142b84d6ba5cc1805bd2263d3b6cb3 100644 (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;
 }