For safety, replace a tuple entry before decreffing it.

This commit is contained in:
Raymond Hettinger 2003-08-30 00:10:06 +00:00
parent a56f6b6600
commit 4f01f89b8c
1 changed files with 3 additions and 1 deletions

View File

@ -1591,6 +1591,7 @@ izip_next(izipobject *lz)
PyObject *result = lz->result; PyObject *result = lz->result;
PyObject *it; PyObject *it;
PyObject *item; PyObject *item;
PyObject *olditem;
if (tuplesize == 0) if (tuplesize == 0)
return NULL; return NULL;
@ -1604,8 +1605,9 @@ izip_next(izipobject *lz)
Py_DECREF(result); Py_DECREF(result);
return NULL; return NULL;
} }
Py_DECREF(PyTuple_GET_ITEM(result, i)); olditem = PyTuple_GET_ITEM(result, i);
PyTuple_SET_ITEM(result, i, item); PyTuple_SET_ITEM(result, i, item);
Py_DECREF(olditem);
} }
} else { } else {
result = PyTuple_New(tuplesize); result = PyTuple_New(tuplesize);