diff options
author | Taylor Holberton <tay10r@protonmail.com> | 2020-04-10 07:28:22 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-10 07:28:22 -0400 |
commit | cb1d5fa164e23c9389cd7aae8c45c04db95309f9 (patch) | |
tree | 516adb8d12b18fb3ae271f0d69ee628d77deb1a0 | |
parent | e05e532312837c24cf0a2d82104efaa7e8b49515 (diff) | |
parent | 00f5aa1337b7a757d07021c5c16f37eaae96dcb3 (diff) |
Merge pull request #148 from lkundrak/lr/double-free
pcm: avoid calling pcm_hw->close() twice
-rw-r--r-- | src/pcm.c | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -898,7 +898,7 @@ struct pcm *pcm_open(unsigned int card, unsigned int device, if (!pcm->snd_node || pcm_type != SND_NODE_TYPE_PLUGIN) { oops(pcm, -ENODEV, "no device (hw/plugin) for card(%u), device(%u)", card, device); - return pcm; + goto fail_close; } pcm->ops = &plug_ops; pcm->fd = pcm->ops->open(card, device, flags, &pcm->data, pcm->snd_node); @@ -907,7 +907,7 @@ struct pcm *pcm_open(unsigned int card, unsigned int device, if (pcm->fd < 0) { oops(pcm, errno, "cannot open device (%u) for card (%u)", device, card); - return pcm; + goto fail_close; } pcm->flags = flags; @@ -954,9 +954,8 @@ fail_close: if (pcm->snd_node) snd_utils_close_dev_node(pcm->snd_node); #endif - pcm->ops->close(pcm->data); - pcm->fd = -1; - return pcm; + pcm_close(pcm); + return &bad_pcm; } /** Checks if a PCM file has been opened without error. |