summaryrefslogtreecommitdiffstats
path: root/Objects/iterobject.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-09-01 07:02:44 (GMT)
committerRaymond Hettinger <python@rcn.com>2004-09-01 07:02:44 (GMT)
commit75ccea3777f77f001102493170490874166eb3b2 (patch)
tree31c6cc1fc38e8928475d7dd3a04fe3e3d0b0a33c /Objects/iterobject.c
parent410eb84a5d4e582491701d63d154959c05a457f4 (diff)
downloadcpython-75ccea3777f77f001102493170490874166eb3b2.zip
cpython-75ccea3777f77f001102493170490874166eb3b2.tar.gz
cpython-75ccea3777f77f001102493170490874166eb3b2.tar.bz2
SF patch #1020188: Use Py_CLEAR where necessary to avoid crashes
(Contributed by Dima Dorfman)
Diffstat (limited to 'Objects/iterobject.c')
-rw-r--r--Objects/iterobject.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/Objects/iterobject.c b/Objects/iterobject.c
index 25e4e11..b414cc2 100644
--- a/Objects/iterobject.c
+++ b/Objects/iterobject.c
@@ -192,18 +192,14 @@ calliter_iternext(calliterobject *it)
return result; /* Common case, fast path */
Py_DECREF(result);
if (ok > 0) {
- Py_DECREF(it->it_callable);
- it->it_callable = NULL;
- Py_DECREF(it->it_sentinel);
- it->it_sentinel = NULL;
+ Py_CLEAR(it->it_callable);
+ Py_CLEAR(it->it_sentinel);
}
}
else if (PyErr_ExceptionMatches(PyExc_StopIteration)) {
PyErr_Clear();
- Py_DECREF(it->it_callable);
- it->it_callable = NULL;
- Py_DECREF(it->it_sentinel);
- it->it_sentinel = NULL;
+ Py_CLEAR(it->it_callable);
+ Py_CLEAR(it->it_sentinel);
}
}
return NULL;