diff options
Diffstat (limited to 'Modules/arraymodule.c')
-rw-r--r-- | Modules/arraymodule.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index f147115..5350759 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -1067,13 +1067,25 @@ Insert a new item x into the array before position i."); static PyObject * array_buffer_info(arrayobject *self, PyObject *unused) { - PyObject* retval = NULL; + PyObject *retval = NULL, *v; + retval = PyTuple_New(2); if (!retval) return NULL; - PyTuple_SET_ITEM(retval, 0, PyLong_FromVoidPtr(self->ob_item)); - PyTuple_SET_ITEM(retval, 1, PyInt_FromLong((long)(Py_SIZE(self)))); + v = PyLong_FromVoidPtr(self->ob_item); + if (v == NULL) { + Py_DECREF(retval); + return NULL; + } + PyTuple_SET_ITEM(retval, 0, v); + + v = PyLong_FromSsize_t(Py_SIZE(self)); + if (v == NULL) { + Py_DECREF(retval); + return NULL; + } + PyTuple_SET_ITEM(retval, 1, v); return retval; } |