Kaydet (Commit) 6ad22c41 authored tarafından Tim Peters's avatar Tim Peters

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

üst 8ae2df48
...@@ -1291,13 +1291,17 @@ PySequence_List(PyObject *v) ...@@ -1291,13 +1291,17 @@ PySequence_List(PyObject *v)
break; break;
} }
if (i < n) if (i < n)
PyList_SET_ITEM(result, i, item); PyList_SET_ITEM(result, i, item); /* steals ref */
else if (PyList_Append(result, item) < 0) { else {
int status = PyList_Append(result, item);
Py_DECREF(item); /* append creates a new ref */
if (status < 0) {
Py_DECREF(result); Py_DECREF(result);
result = NULL; result = NULL;
break; break;
} }
} }
}
/* Cut back result list if initial guess was too large. */ /* Cut back result list if initial guess was too large. */
if (i < n && result != NULL) { if (i < n && result != NULL) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment