[Python-checkins] CVS: python/dist/src/Objects stringobject.c,2.128,2.129
Guido van Rossum
gvanrossum@users.sourceforge.net
Fri, 31 Aug 2001 09:11:17 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv20697
Modified Files:
stringobject.c
Log Message:
Fix a memory leak in str_subtype_new(). (All the other
xxx_subtype_new() functions are OK, but I goofed up in this one. :-( )
Index: stringobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v
retrieving revision 2.128
retrieving revision 2.129
diff -C2 -d -r2.128 -r2.129
*** stringobject.c 2001/08/30 03:11:59 2.128
--- stringobject.c 2001/08/31 16:11:15 2.129
***************
*** 2714,2720 ****
assert(PyString_Check(tmp));
new = type->tp_alloc(type, n = PyString_GET_SIZE(tmp));
! if (new == NULL)
! return NULL;
! memcpy(PyString_AS_STRING(new), PyString_AS_STRING(tmp), n+1);
return new;
}
--- 2714,2720 ----
assert(PyString_Check(tmp));
new = type->tp_alloc(type, n = PyString_GET_SIZE(tmp));
! if (new != NULL)
! memcpy(PyString_AS_STRING(new), PyString_AS_STRING(tmp), n+1);
! Py_DECREF(tmp);
return new;
}