[Python-checkins] CVS: python/dist/src/Objects stringobject.c,2.77,2.78
Jeremy Hylton
python-dev@python.org
Mon, 10 Jul 2000 20:28:20 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory slayer.i.sourceforge.net:/tmp/cvs-serv20163/Objects
Modified Files:
stringobject.c
Log Message:
fix two refcount bugs in new string_join implementation:
1. PySequence_Fast_GET_ITEM is a macro and borrows a reference
2. The seq returned from PySequence_Fast must be decref'd
Index: stringobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v
retrieving revision 2.77
retrieving revision 2.78
diff -C2 -r2.77 -r2.78
*** stringobject.c 2000/07/10 21:30:28 2.77
--- stringobject.c 2000/07/11 03:28:17 2.78
***************
*** 775,779 ****
if (PyUnicode_Check(item)) {
Py_DECREF(res);
- Py_DECREF(item);
return PyUnicode_Join((PyObject *)self,
seq);
--- 775,778 ----
***************
*** 782,787 ****
"sequence item %i: expected string, %.80s found",
i, item->ob_type->tp_name);
- Py_DECREF(item);
- Py_DECREF(seq);
goto finally;
}
--- 781,784 ----
***************
*** 789,794 ****
while (reslen + slen + seplen >= sz) {
if (_PyString_Resize(&res, sz*2)) {
- Py_DECREF(item);
- Py_DECREF(seq);
goto finally;
}
--- 786,789 ----
***************
*** 802,806 ****
}
memcpy(p, PyString_AS_STRING(item), slen);
- Py_DECREF(item);
p += slen;
reslen += slen;
--- 797,800 ----
***************
*** 808,814 ****
--- 802,810 ----
if (_PyString_Resize(&res, reslen))
goto finally;
+ Py_DECREF(seq);
return res;
finally:
+ Py_DECREF(seq);
Py_DECREF(res);
return NULL;