Replace structure member before decreffing.

This commit is contained in:
Raymond Hettinger 2004-10-02 10:56:43 +00:00
parent 4c3d054d3d
commit 880430e2a5

View file

@ -662,6 +662,7 @@ cycle_next(cycleobject *lz)
{ {
PyObject *item; PyObject *item;
PyObject *it; PyObject *it;
PyObject *tmp;
while (1) { while (1) {
item = PyIter_Next(lz->it); item = PyIter_Next(lz->it);
@ -681,9 +682,10 @@ cycle_next(cycleobject *lz)
it = PyObject_GetIter(lz->saved); it = PyObject_GetIter(lz->saved);
if (it == NULL) if (it == NULL)
return NULL; return NULL;
Py_DECREF(lz->it); tmp = lz->it;
lz->it = it; lz->it = it;
lz->firstpass = 1; lz->firstpass = 1;
Py_DECREF(tmp);
} }
} }