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