From b2aefd77e1da438aed649d018d6aa504ec35eac8 Mon Sep 17 00:00:00 2001 From: stratakis Date: Wed, 6 Mar 2019 15:11:56 +0100 Subject: [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. --- Misc/NEWS.d/next/Library/2019-03-04-16-39-16.bpo-36186.Hqw1A_.rst | 1 + Modules/linuxaudiodev.c | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2019-03-04-16-39-16.bpo-36186.Hqw1A_.rst 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 index 0000000..a14d155 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2019-03-04-16-39-16.bpo-36186.Hqw1A_.rst @@ -0,0 +1 @@ +Fix linuxaudiodev.linux_audio_device() error handling: close the internal file descriptor if it fails to open the device. diff --git a/Modules/linuxaudiodev.c b/Modules/linuxaudiodev.c index 7fe20ae..f5135d9 100644 --- a/Modules/linuxaudiodev.c +++ b/Modules/linuxaudiodev.c @@ -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 */ -- cgit v0.12