]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[2.7] bpo-36186: Fix linuxaudiodev.linux_audio_device() error handling (GH-12163)
authorstratakis <cstratak@redhat.com>
Wed, 6 Mar 2019 14:11:56 +0000 (15:11 +0100)
committerVictor Stinner <vstinner@redhat.com>
Wed, 6 Mar 2019 14:11:56 +0000 (15:11 +0100)
Fix linuxaudiodev.linux_audio_device() error handling:
close the internal file descriptor if it fails to open the device.

Misc/NEWS.d/next/Library/2019-03-04-16-39-16.bpo-36186.Hqw1A_.rst [new file with mode: 0644]
Modules/linuxaudiodev.c

diff --git a/Misc/NEWS.d/next/Library/2019-03-04-16-39-16.bpo-36186.Hqw1A_.rst b/Misc/NEWS.d/next/Library/2019-03-04-16-39-16.bpo-36186.Hqw1A_.rst
new file mode 100644 (file)
index 0000000..a14d155
--- /dev/null
@@ -0,0 +1 @@
+Fix linuxaudiodev.linux_audio_device() error handling: close the internal file descriptor if it fails to open the device.
index 7fe20ae19544c74527d20deed38c6bc193397fad..f5135d9112900b6cbe99cb0bb89b80468b0398b4 100644 (file)
@@ -126,10 +126,12 @@ newladobject(PyObject *arg)
     }
     if (imode == O_WRONLY && ioctl(fd, SNDCTL_DSP_NONBLOCK, NULL) == -1) {
         PyErr_SetFromErrnoWithFilename(LinuxAudioError, basedev);
+        close(fd);
         return NULL;
     }
     if (ioctl(fd, SNDCTL_DSP_GETFMTS, &afmts) == -1) {
         PyErr_SetFromErrnoWithFilename(LinuxAudioError, basedev);
+        close(fd);
         return NULL;
     }
     /* Create and initialize the object */