mirror of https://github.com/python/cpython
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.
This commit is contained in:
parent
83f5291c0f
commit
85004cc47d
|
@ -1758,13 +1758,18 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
PyObject *v =
|
PyObject *v =
|
||||||
PySequence_GetItem(initial, i);
|
PySequence_GetItem(initial, i);
|
||||||
if (setarrayitem(a, i, v) != 0) {
|
if (v == NULL) {
|
||||||
Py_DECREF(a);
|
Py_DECREF(a);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
if (setarrayitem(a, i, v) != 0) {
|
||||||
|
Py_DECREF(v);
|
||||||
|
Py_DECREF(a);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
Py_DECREF(v);
|
||||||
}
|
}
|
||||||
}
|
} else if (initial != NULL && PyString_Check(initial)) {
|
||||||
if (initial != NULL && PyString_Check(initial)) {
|
|
||||||
PyObject *t_initial = Py_BuildValue("(O)",
|
PyObject *t_initial = Py_BuildValue("(O)",
|
||||||
initial);
|
initial);
|
||||||
PyObject *v =
|
PyObject *v =
|
||||||
|
|
Loading…
Reference in New Issue