From: stratakis Date: Wed, 6 Mar 2019 14:11:56 +0000 (+0100) Subject: [2.7] bpo-36186: Fix linuxaudiodev.linux_audio_device() error handling (GH-12163) X-Git-Tag: v2.7.17rc1~131 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b2aefd77e1da438aed649d018d6aa504ec35eac8;p=thirdparty%2FPython%2Fcpython.git [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. --- 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 000000000000..a14d155ae973 --- /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 7fe20ae19544..f5135d911290 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 */