summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Modules/itertoolsmodule.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c
index e2e820e..0a20c1b 100644
--- a/Modules/itertoolsmodule.c
+++ b/Modules/itertoolsmodule.c
@@ -1010,8 +1010,10 @@ chain_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
/* create chainobject structure */
lz = (chainobject *)type->tp_alloc(type, 0);
- if (lz == NULL)
+ if (lz == NULL) {
+ Py_DECREF(ittuple);
return NULL;
+ }
lz->ittuple = ittuple;
lz->iternum = 0;