diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 0c6f542..3df26da 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -4474,6 +4474,7 @@ PyCArrayType_from_ctype(PyObject *itemtype, Py_ssize_t length) if (!PyType_Check(itemtype)) { PyErr_SetString(PyExc_TypeError, "Expected a type object"); + Py_DECREF(key); return NULL; } #ifdef MS_WIN64