From: Victor Stinner Date: Thu, 14 Nov 2013 00:27:12 +0000 (+0100) Subject: Issue #19437: Fix array.buffer_info(), handle PyLong_FromVoidPtr() and X-Git-Tag: v3.4.0b1~285^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=541067a64077998b486be183fdaffec42fe3fae8;p=thirdparty%2FPython%2Fcpython.git Issue #19437: Fix array.buffer_info(), handle PyLong_FromVoidPtr() and PyLong_FromLong() failure --- diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index 75b31f5b5e46..3466064a3d4b 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; }