Plug a memory leak in list(), when appending to the result list.

This commit is contained in:
Tim Peters 2001-05-02 07:12:39 +00:00
parent 8ae2df483c
commit 6ad22c41c2
1 changed files with 9 additions and 5 deletions

View File

@ -1291,11 +1291,15 @@ PySequence_List(PyObject *v)
break;
}
if (i < n)
PyList_SET_ITEM(result, i, item);
else if (PyList_Append(result, item) < 0) {
Py_DECREF(result);
result = NULL;
break;
PyList_SET_ITEM(result, i, item); /* steals ref */
else {
int status = PyList_Append(result, item);
Py_DECREF(item); /* append creates a new ref */
if (status < 0) {
Py_DECREF(result);
result = NULL;
break;
}
}
}