summaryrefslogtreecommitdiffstats
path: root/Modules/itertoolsmodule.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2003-08-30 00:10:06 (GMT)
committerRaymond Hettinger <python@rcn.com>2003-08-30 00:10:06 (GMT)
commit4f01f89b8c35235acfc93bcc4f6fe1b2645c0295 (patch)
treeee7a2e5d11a9b4942316825447091a5e77ff6701 /Modules/itertoolsmodule.c
parenta56f6b6600ea8906562cfaa31859b72a53a8c0d7 (diff)
downloadcpython-4f01f89b8c35235acfc93bcc4f6fe1b2645c0295.zip
cpython-4f01f89b8c35235acfc93bcc4f6fe1b2645c0295.tar.gz
cpython-4f01f89b8c35235acfc93bcc4f6fe1b2645c0295.tar.bz2
For safety, replace a tuple entry before decreffing it.
Diffstat (limited to 'Modules/itertoolsmodule.c')
-rw-r--r--Modules/itertoolsmodule.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c
index 4dca054..68e176f 100644
--- a/Modules/itertoolsmodule.c
+++ b/Modules/itertoolsmodule.c
@@ -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);