[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.
This commit is contained in:
stratakis 2019-03-06 15:11:56 +01:00 committed by Victor Stinner
parent 84772e0ab4
commit b2aefd77e1
2 changed files with 3 additions and 0 deletions

View File

@ -0,0 +1 @@
Fix linuxaudiodev.linux_audio_device() error handling: close the internal file descriptor if it fails to open the device.

View 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 */