comparison Objects/typeobject.c @ 25838:8540887bcec6 2.2

Backport of 2.183: Fix memory leak in add_subclass() found by NealN with valgrind.
author Guido van Rossum <guido@python.org>
date Fri, 18 Oct 2002 13:42:21 +0000
parents e374ea7ac4ce
children eea40c417205
comparison
equal deleted inserted replaced
25834:035b8deb52c1 25838:8540887bcec6
2247 new = PyWeakref_NewRef((PyObject *)type, NULL); 2247 new = PyWeakref_NewRef((PyObject *)type, NULL);
2248 i = PyList_GET_SIZE(list); 2248 i = PyList_GET_SIZE(list);
2249 while (--i >= 0) { 2249 while (--i >= 0) {
2250 ref = PyList_GET_ITEM(list, i); 2250 ref = PyList_GET_ITEM(list, i);
2251 assert(PyWeakref_CheckRef(ref)); 2251 assert(PyWeakref_CheckRef(ref));
2252 if (PyWeakref_GET_OBJECT(ref) == Py_None) 2252 if (PyWeakref_GET_OBJECT(ref) == Py_None) {
2253 return PyList_SetItem(list, i, new); 2253 i = PyList_SetItem(list, i, new);
2254 Py_DECREF(new);
2255 return i;
2256 }
2254 } 2257 }
2255 i = PyList_Append(list, new); 2258 i = PyList_Append(list, new);
2256 Py_DECREF(new); 2259 Py_DECREF(new);
2257 return i; 2260 return i;
2258 } 2261 }