commit | a7b0c12152e6268bb09b462f2a0fe52178ee6065 | [log] [tgz] |
---|---|---|
author | Benjamin Peterson <benjamin@python.org> | Mon Feb 16 21:23:04 2009 +0000 |
committer | Benjamin Peterson <benjamin@python.org> | Mon Feb 16 21:23:04 2009 +0000 |
tree | a35b2baf6823fece1c491137752fe88815b165c4 | |
parent | 5781f32b4f8d9dd35e9980d4da99d1420339e920 [diff] |
PyList_Append() can fail
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 @@ 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()) {