mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
For safety, replace a tuple entry before decreffing it.
This commit is contained in:
parent
a56f6b6600
commit
4f01f89b8c
1 changed files with 3 additions and 1 deletions
|
@ -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);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue