diff options
author | Michael W. Hudson <mwh@python.net> | 2003-08-08 13:57:22 (GMT) |
---|---|---|
committer | Michael W. Hudson <mwh@python.net> | 2003-08-08 13:57:22 (GMT) |
commit | a6a277d8316973ca3f546e5111430a8c4ee07181 (patch) | |
tree | be86e0c44de03f5533d9572a3f92f5b7b9e50e7d | |
parent | 5475f2394abea43c541d8660ed91af920634add5 (diff) | |
download | cpython-a6a277d8316973ca3f546e5111430a8c4ee07181.zip cpython-a6a277d8316973ca3f546e5111430a8c4ee07181.tar.gz cpython-a6a277d8316973ca3f546e5111430a8c4ee07181.tar.bz2 |
/* XXX From here until type is allocated, "return NULL" leaks bases! */
Sure looks like it to me! <wink>
When I run the leak2.py script I posted to python-dev, I only see
three reference leaks in all of test_descr. When I run
test_descr.test_main, I still see 46 leaks. This clearly demands
posting a yelp to python-dev :-)
This certainly should be applied to release23-maint, and in all
likelyhood release22-maint as well.
-rw-r--r-- | Objects/typeobject.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 2a7df8a..5c0f73a 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -1618,12 +1618,15 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds) /* Calculate best base, and check that all bases are type objects */ base = best_base(bases); - if (base == NULL) + if (base == NULL) { + Py_DECREF(bases); return NULL; + } if (!PyType_HasFeature(base, Py_TPFLAGS_BASETYPE)) { PyErr_Format(PyExc_TypeError, "type '%.100s' is not an acceptable base type", base->tp_name); + Py_DECREF(bases); return NULL; } @@ -1650,8 +1653,10 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds) slots = Py_BuildValue("(O)", slots); else slots = PySequence_Tuple(slots); - if (slots == NULL) + if (slots == NULL) { + Py_DECREF(bases); return NULL; + } assert(PyTuple_Check(slots)); /* Are slots allowed? */ @@ -1662,6 +1667,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds) "not supported for subtype of '%s'", base->tp_name); bad_slots: + Py_DECREF(bases); Py_DECREF(slots); return NULL; } @@ -1773,6 +1779,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds) type = (PyTypeObject *)metatype->tp_alloc(metatype, nslots); if (type == NULL) { Py_XDECREF(slots); + Py_DECREF(bases); return NULL; } |