[Python-checkins] cpython: Issue #19437: Fix array.buffer_info(), handle PyLong_FromVoidPtr() and
victor.stinner
python-checkins at python.org
Thu Nov 14 01:47:14 CET 2013
http://hg.python.org/cpython/rev/285d28c3620a
changeset: 87092:285d28c3620a
user: Victor Stinner <victor.stinner at gmail.com>
date: Thu Nov 14 01:27:12 2013 +0100
summary:
Issue #19437: Fix array.buffer_info(), handle PyLong_FromVoidPtr() and
PyLong_FromLong() failure
files:
Modules/arraymodule.c | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c
--- a/Modules/arraymodule.c
+++ b/Modules/arraymodule.c
@@ -1133,13 +1133,25 @@
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;
}
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list