[Python-checkins] python/dist/src/Objects enumobject.c, 1.17,
1.18 genobject.c, 1.3, 1.4 iterobject.c, 1.18, 1.19
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Wed Sep 1 09:03:03 CEST 2004
Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13289/Objects
Modified Files:
enumobject.c genobject.c iterobject.c
Log Message:
SF patch #1020188: Use Py_CLEAR where necessary to avoid crashes
(Contributed by Dima Dorfman)
Index: enumobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/enumobject.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- enumobject.c 25 Aug 2004 19:42:12 -0000 1.17
+++ enumobject.c 1 Sep 2004 07:02:44 -0000 1.18
@@ -230,10 +230,7 @@
PyErr_Clear();
}
ro->index = -1;
- if (ro->seq != NULL) {
- Py_DECREF(ro->seq);
- ro->seq = NULL;
- }
+ Py_CLEAR(ro->seq);
return NULL;
}
Index: genobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/genobject.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- genobject.c 27 Jun 2004 15:43:12 -0000 1.3
+++ genobject.c 1 Sep 2004 07:02:44 -0000 1.4
@@ -51,8 +51,7 @@
* may keep a chain of frames alive or it could create a reference
* cycle. */
assert(f->f_back != NULL);
- Py_DECREF(f->f_back);
- f->f_back = NULL;
+ Py_CLEAR(f->f_back);
/* If the generator just returned (as opposed to yielding), signal
* that the generator is exhausted. */
Index: iterobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/iterobject.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- iterobject.c 12 Apr 2004 18:10:01 -0000 1.18
+++ iterobject.c 1 Sep 2004 07:02:44 -0000 1.19
@@ -192,18 +192,14 @@
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;
More information about the Python-checkins
mailing list