]> granicus.if.org Git - python/commitdiff
Fix refleaks in _ctypes PyCSimpleType_New, which fixes the refleak seen in test___all__.
authorGeorg Brandl <georg@python.org>
Sat, 17 Oct 2009 08:57:43 +0000 (08:57 +0000)
committerGeorg Brandl <georg@python.org>
Sat, 17 Oct 2009 08:57:43 +0000 (08:57 +0000)
Modules/_ctypes/_ctypes.c

index c4f73ba451928598ac490f4902ed57abdf0fbecd..4d2302d8ae308f65c6c7994d4e71bbb4d2f11f4e 100644 (file)
@@ -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;
        }