[Python-checkins] python/dist/src/Objects typeobject.c,2.182,2.183
gvanrossum@users.sourceforge.net
gvanrossum@users.sourceforge.net
2002年10月18日 06:41:49 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv5985
Modified Files:
typeobject.c
Log Message:
Fix memory leak in add_subclass() found by NealN with valgrind.
Will backport.
Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.182
retrieving revision 2.183
diff -C2 -d -r2.182 -r2.183
*** typeobject.c 15 Oct 2002 00:57:28 -0000 2.182
--- typeobject.c 18 Oct 2002 13:41:47 -0000 2.183
***************
*** 2469,2474 ****
ref = PyList_GET_ITEM(list, i);
assert(PyWeakref_CheckRef(ref));
! if (PyWeakref_GET_OBJECT(ref) == Py_None)
! return PyList_SetItem(list, i, new);
}
i = PyList_Append(list, new);
--- 2469,2477 ----
ref = PyList_GET_ITEM(list, i);
assert(PyWeakref_CheckRef(ref));
! if (PyWeakref_GET_OBJECT(ref) == Py_None) {
! i = PyList_SetItem(list, i, new);
! Py_DECREF(new);
! return i;
! }
}
i = PyList_Append(list, new);