Ensure that dataobj is never NULL.
Reported by Klocwork #102
{
if (tdo->nextlink == NULL)
tdo->nextlink = teedataobject_new(tdo->it);
- Py_INCREF(tdo->nextlink);
+ Py_XINCREF(tdo->nextlink);
return tdo->nextlink;
}
if (to->index >= LINKCELLS) {
link = teedataobject_jumplink(to->dataobj);
- Py_XDECREF(to->dataobj);
+ Py_DECREF(to->dataobj);
to->dataobj = (teedataobject *)link;
to->index = 0;
}
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);