Commit 85004cc4 authored by Raymond Hettinger's avatar Raymond Hettinger

SF bug #782369: Massive memory leak in array module

Fixed leak caused by switching from PyList_GetItem to PySequence_GetItem.
Added missing NULL check.
Clarified code by converting an "if" to an "else if".

Will backport to 2.3.
parent 83f5291c
......@@ -1758,13 +1758,18 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
for (i = 0; i < len; i++) {
PyObject *v =
PySequence_GetItem(initial, i);
if (v == NULL) {
Py_DECREF(a);
return NULL;
}
if (setarrayitem(a, i, v) != 0) {
Py_DECREF(v);
Py_DECREF(a);
return NULL;
}
Py_DECREF(v);
}
}
if (initial != NULL && PyString_Check(initial)) {
} else if (initial != NULL && PyString_Check(initial)) {
PyObject *t_initial = Py_BuildValue("(O)",
initial);
PyObject *v =
......
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