PyType_stgdict() returns a borrowed reference which must not be Py_DECREF'd.
This bug should be fixed in trunk and release25-maint also.
diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c
index 07e142b..c35a515 100644
--- a/Modules/_ctypes/stgdict.c
+++ b/Modules/_ctypes/stgdict.c
@@ -465,13 +465,11 @@
if (!prop) {
Py_DECREF(pair);
- Py_DECREF((PyObject *)stgdict);
return -1;
}
if (-1 == PyDict_SetItem(realdict, name, prop)) {
Py_DECREF(prop);
Py_DECREF(pair);
- Py_DECREF((PyObject *)stgdict);
return -1;
}
Py_DECREF(pair);