summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Misc/NEWS2
-rw-r--r--Modules/arraymodule.c9
2 files changed, 9 insertions, 2 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index d46a5e2..45bf3e5 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -24,6 +24,8 @@ Library
- Bug #781065: test_normalization is updated to the current
URL of the Unicode 3.2 normalization file.
+- Bug #782369: fix memory leak in array module.
+
IDLE
----
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c
index f730915..228c8f4 100644
--- a/Modules/arraymodule.c
+++ b/Modules/arraymodule.c
@@ -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 =