summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-02-16 21:23:04 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-02-16 21:23:04 (GMT)
commita7b0c12152e6268bb09b462f2a0fe52178ee6065 (patch)
treea35b2baf6823fece1c491137752fe88815b165c4 /Modules
parent5781f32b4f8d9dd35e9980d4da99d1420339e920 (diff)
downloadcpython-a7b0c12152e6268bb09b462f2a0fe52178ee6065.zip
cpython-a7b0c12152e6268bb09b462f2a0fe52178ee6065.tar.gz
cpython-a7b0c12152e6268bb09b462f2a0fe52178ee6065.tar.bz2
PyList_Append() can fail
Diffstat (limited to 'Modules')
-rw-r--r--Modules/itertoolsmodule.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c
index f42232d..fefcbfb 100644
--- a/Modules/itertoolsmodule.c
+++ b/Modules/itertoolsmodule.c
@@ -745,8 +745,10 @@ cycle_next(cycleobject *lz)
while (1) {
item = PyIter_Next(lz->it);
if (item != NULL) {
- if (!lz->firstpass)
- PyList_Append(lz->saved, item);
+ if (!lz->firstpass && PyList_Append(lz->saved, item)) {
+ Py_DECREF(item);
+ return NULL;
+ }
return item;
}
if (PyErr_Occurred()) {