diff options
author | Guido van Rossum <guido@python.org> | 2002-10-18 13:41:47 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2002-10-18 13:41:47 (GMT) |
commit | 72297bb71e3b0dd420c94fa5ed90038e445334d8 (patch) | |
tree | d61edca129e77f3b4902429cbf3bb98c6df99027 /Objects | |
parent | e4913c9987d88f5a1bd52753afe8eb6bee32f6e9 (diff) | |
download | cpython-72297bb71e3b0dd420c94fa5ed90038e445334d8.zip cpython-72297bb71e3b0dd420c94fa5ed90038e445334d8.tar.gz cpython-72297bb71e3b0dd420c94fa5ed90038e445334d8.tar.bz2 |
Fix memory leak in add_subclass() found by NealN with valgrind.
Will backport.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/typeobject.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index ed5b829..cc60d6c 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -2468,8 +2468,11 @@ add_subclass(PyTypeObject *base, PyTypeObject *type) while (--i >= 0) { ref = PyList_GET_ITEM(list, i); assert(PyWeakref_CheckRef(ref)); - if (PyWeakref_GET_OBJECT(ref) == Py_None) - return PyList_SetItem(list, i, new); + if (PyWeakref_GET_OBJECT(ref) == Py_None) { + i = PyList_SetItem(list, i, new); + Py_DECREF(new); + return i; + } } i = PyList_Append(list, new); Py_DECREF(new); |