[2.7] bpo-36186: Fix linuxaudiodev.linux_audio_device() error handlin… · python/cpython@b2aefd7

Original file line numberDiff line numberDiff line change

@@ -126,10 +126,12 @@ newladobject(PyObject *arg)

126126

}

127127

if (imode == O_WRONLY && ioctl(fd, SNDCTL_DSP_NONBLOCK, NULL) == -1) {

128128

PyErr_SetFromErrnoWithFilename(LinuxAudioError, basedev);

129+

close(fd);

129130

return NULL;

130131

}

131132

if (ioctl(fd, SNDCTL_DSP_GETFMTS, &afmts) == -1) {

132133

PyErr_SetFromErrnoWithFilename(LinuxAudioError, basedev);

134+

close(fd);

133135

return NULL;

134136

}

135137

/* Create and initialize the object */