[Python-checkins] r50782 - python/trunk/Modules/itertoolsmodule.c
neal.norwitz
python-checkins at python.org
Sun Jul 23 09:59:00 CEST 2006
Author: neal.norwitz
Date: Sun Jul 23 09:59:00 2006
New Revision: 50782
Modified:
python/trunk/Modules/itertoolsmodule.c
Log:
nextlink can be NULL if teedataobject_new fails, so use XINCREF.
Ensure that dataobj is never NULL.
Reported by Klocwork #102
Modified: python/trunk/Modules/itertoolsmodule.c
==============================================================================
--- python/trunk/Modules/itertoolsmodule.c (original)
+++ python/trunk/Modules/itertoolsmodule.c Sun Jul 23 09:59:00 2006
@@ -357,7 +357,7 @@
{
if (tdo->nextlink == NULL)
tdo->nextlink = teedataobject_new(tdo->it);
- Py_INCREF(tdo->nextlink);
+ Py_XINCREF(tdo->nextlink);
return tdo->nextlink;
}
@@ -468,7 +468,7 @@
if (to->index >= LINKCELLS) {
link = teedataobject_jumplink(to->dataobj);
- Py_XDECREF(to->dataobj);
+ Py_DECREF(to->dataobj);
to->dataobj = (teedataobject *)link;
to->index = 0;
}
@@ -522,6 +522,12 @@
if (to == NULL)
goto done;
to->dataobj = (teedataobject *)teedataobject_new(it);
+ if (!to->dataobj) {
+ PyObject_GC_Del(to);
+ to = NULL;
+ goto done;
+ }
+
to->index = 0;
to->weakreflist = NULL;
PyObject_GC_Track(to);
More information about the Python-checkins
mailing list