summaryrefslogtreecommitdiffstats
path: root/Modules/arraymodule.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-11-14 00:27:12 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-11-14 00:27:12 (GMT)
commit541067a64077998b486be183fdaffec42fe3fae8 (patch)
treed66c58eb3e8ac854837f8126af2e046eae0a90ae /Modules/arraymodule.c
parent804e05e800163e6982b036b025b6333b17d9b3a0 (diff)
downloadcpython-541067a64077998b486be183fdaffec42fe3fae8.zip
cpython-541067a64077998b486be183fdaffec42fe3fae8.tar.gz
cpython-541067a64077998b486be183fdaffec42fe3fae8.tar.bz2
Issue #19437: Fix array.buffer_info(), handle PyLong_FromVoidPtr() and
PyLong_FromLong() failure
Diffstat (limited to 'Modules/arraymodule.c')
-rw-r--r--Modules/arraymodule.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c
index 75b31f5..3466064 100644
--- a/Modules/arraymodule.c
+++ b/Modules/arraymodule.c
@@ -1133,13 +1133,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, PyLong_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_FromLong((long)(Py_SIZE(self)));
+ if (v == NULL) {
+ Py_DECREF(retval);
+ return NULL;
+ }
+ PyTuple_SET_ITEM(retval, 1, v);
return retval;
}