Commit b2aefd77 authored by stratakis's avatar stratakis Committed by Victor Stinner

[2.7] bpo-36186: Fix linuxaudiodev.linux_audio_device() error handling (GH-12163)

Fix linuxaudiodev.linux_audio_device() error handling:
close the internal file descriptor if it fails to open the device.
parent 84772e0a
Fix linuxaudiodev.linux_audio_device() error handling: close the internal file descriptor if it fails to open the device.
...@@ -126,10 +126,12 @@ newladobject(PyObject *arg) ...@@ -126,10 +126,12 @@ newladobject(PyObject *arg)
} }
if (imode == O_WRONLY && ioctl(fd, SNDCTL_DSP_NONBLOCK, NULL) == -1) { if (imode == O_WRONLY && ioctl(fd, SNDCTL_DSP_NONBLOCK, NULL) == -1) {
PyErr_SetFromErrnoWithFilename(LinuxAudioError, basedev); PyErr_SetFromErrnoWithFilename(LinuxAudioError, basedev);
close(fd);
return NULL; return NULL;
} }
if (ioctl(fd, SNDCTL_DSP_GETFMTS, &afmts) == -1) { if (ioctl(fd, SNDCTL_DSP_GETFMTS, &afmts) == -1) {
PyErr_SetFromErrnoWithFilename(LinuxAudioError, basedev); PyErr_SetFromErrnoWithFilename(LinuxAudioError, basedev);
close(fd);
return NULL; return NULL;
} }
/* Create and initialize the object */ /* Create and initialize the object */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment