From 880430e2a54d4f47baef3515072e7119e85510f7 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Sat, 2 Oct 2004 10:56:43 +0000 Subject: Replace structure member before decreffing. --- Modules/itertoolsmodule.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c index 3da0258..4069ea2 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -662,6 +662,7 @@ cycle_next(cycleobject *lz) { PyObject *item; PyObject *it; + PyObject *tmp; while (1) { item = PyIter_Next(lz->it); @@ -681,9 +682,10 @@ cycle_next(cycleobject *lz) it = PyObject_GetIter(lz->saved); if (it == NULL) return NULL; - Py_DECREF(lz->it); + tmp = lz->it; lz->it = it; lz->firstpass = 1; + Py_DECREF(tmp); } } -- cgit v0.12