[Python-checkins] r75459 - python/trunk/Modules/_ctypes/_ctypes.c

georg.brandl python-checkins at python.org
Sat Oct 17 10:57:43 CEST 2009


Author: georg.brandl
Date: Sat Oct 17 10:57:43 2009
New Revision: 75459

Log:
Fix refleaks in _ctypes PyCSimpleType_New, which fixes the refleak seen in test___all__.

Modified:
   python/trunk/Modules/_ctypes/_ctypes.c

Modified: python/trunk/Modules/_ctypes/_ctypes.c
==============================================================================
--- python/trunk/Modules/_ctypes/_ctypes.c	(original)
+++ python/trunk/Modules/_ctypes/_ctypes.c	Sat Oct 17 10:57:43 2009
@@ -1889,17 +1889,16 @@
 	}
 	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 @@
 #endif
 	if (stgdict->format == NULL) {
 		Py_DECREF(result);
+		Py_DECREF(proto);
 		Py_DECREF((PyObject *)stgdict);
 		return NULL;
 	}


More information about the Python-checkins mailing list