summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Modules/arraymodule.c9
1 files changed, 7 insertions, 2 deletions
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 =