Plug a memory leak in list(), when appending to the result list.
This commit is contained in:
parent
8ae2df483c
commit
6ad22c41c2
|
@ -1291,11 +1291,15 @@ 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 {
|
||||||
Py_DECREF(result);
|
int status = PyList_Append(result, item);
|
||||||
result = NULL;
|
Py_DECREF(item); /* append creates a new ref */
|
||||||
break;
|
if (status < 0) {
|
||||||
|
Py_DECREF(result);
|
||||||
|
result = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue