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()) {