summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-10-17 08:57:43 (GMT)
committerGeorg Brandl <georg@python.org>2009-10-17 08:57:43 (GMT)
commite363b1434d6d659bdb94ab522a9da78f1f5a8bef (patch)
treeb7656717fe0e6dc69f38f1c8d552c7444954ffea
parentb6edf193fbe069e6c1ff3acd4e32dab01c818d7b (diff)
downloadcpython-e363b1434d6d659bdb94ab522a9da78f1f5a8bef.zip
cpython-e363b1434d6d659bdb94ab522a9da78f1f5a8bef.tar.gz
cpython-e363b1434d6d659bdb94ab522a9da78f1f5a8bef.tar.bz2
Fix refleaks in _ctypes PyCSimpleType_New, which fixes the refleak seen in test___all__.
-rw-r--r--Modules/_ctypes/_ctypes.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index c4f73ba..4d2302d 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -1889,17 +1889,16 @@ PyCSimpleType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
}
fmt = _ctypes_get_fielddesc(PyString_AS_STRING(proto));
if (fmt == NULL) {
- Py_DECREF(result);
PyErr_Format(PyExc_ValueError,
"_type_ '%s' not supported",
PyString_AS_STRING(proto));
- return NULL;
+ goto error;
}
stgdict = (StgDictObject *)PyObject_CallObject(
(PyObject *)&PyCStgDict_Type, NULL);
if (!stgdict)
- return NULL;
+ goto error;
stgdict->ffi_type_pointer = *fmt->pffi_type;
stgdict->align = fmt->pffi_type->alignment;
@@ -1914,6 +1913,7 @@ PyCSimpleType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
#endif
if (stgdict->format == NULL) {
Py_DECREF(result);
+ Py_DECREF(proto);
Py_DECREF((PyObject *)stgdict);
return NULL;
}