Issue #13058: ossaudiodev: fix a file descriptor leak on error. Patch by Thomas
Jarosch.
diff --git a/Misc/ACKS b/Misc/ACKS
index 6845faa..408d91b 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -436,6 +436,7 @@
 Geert Jansen
 Jack Jansen
 Bill Janssen
+Thomas Jarosch
 Drew Jenkins
 Flemming Kjær Jensen
 MunSic Jeong
diff --git a/Misc/NEWS b/Misc/NEWS
index b5c75b4..2f6ef7f 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -82,6 +82,9 @@
 Extension Modules
 -----------------
 
+- Issue #13058: ossaudiodev: fix a file descriptor leak on error. Patch by
+  Thomas Jarosch.
+
 - Issue #13013: ctypes: Fix a reference leak in PyCArrayType_from_ctype.
   Thanks to Suman Saha for finding the bug and providing a patch.
 
diff --git a/Modules/ossaudiodev.c b/Modules/ossaudiodev.c
index cdf6beb..b38ce52 100644
--- a/Modules/ossaudiodev.c
+++ b/Modules/ossaudiodev.c
@@ -129,6 +129,7 @@
     }
 
     if (ioctl(fd, SNDCTL_DSP_GETFMTS, &afmts) == -1) {
+        close(fd);
         PyErr_SetFromErrnoWithFilename(PyExc_IOError, devicename);
         return NULL;
     }