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/Misc/ACKS b/Misc/ACKS
index e728c51..6c02a79 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -720,6 +720,7 @@
Mark Russell
Nick Russo
Sébastien Sablé
+Suman Saha
Hajime Saitou
George Sakkis
Rich Salz
diff --git a/Misc/NEWS b/Misc/NEWS
index c4f0cb0..132ea5e 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -207,6 +207,9 @@
Extension Modules
-----------------
+- Issue #13013: ctypes: Fix a reference leak in PyCArrayType_from_ctype.
+ Thanks to Suman Saha for finding the bug and providing a patch.
+
- Issue #13022: Fix: _multiprocessing.recvfd() doesn't check that
file descriptor was actually received.
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index c4d0890..4ae2c41 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -4678,6 +4678,7 @@
if (!PyType_Check(itemtype)) {
PyErr_SetString(PyExc_TypeError,
"Expected a type object");
+ Py_DECREF(key);
return NULL;
}
#ifdef MS_WIN64