mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Fix memory leak in add_subclass() found by NealN with valgrind.
Will backport.
This commit is contained in:
parent
e4913c9987
commit
72297bb71e
1 changed files with 5 additions and 2 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue