]> granicus.if.org Git - python/commitdiff
Issue #19437: Fix array.buffer_info(), handle PyLong_FromVoidPtr() and
authorVictor Stinner <victor.stinner@gmail.com>
Thu, 14 Nov 2013 00:27:12 +0000 (01:27 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Thu, 14 Nov 2013 00:27:12 +0000 (01:27 +0100)
PyLong_FromLong() failure

Modules/arraymodule.c

index 75b31f5b5e463f8fbdb1e31479d77c394ba63dfb..3466064a3d4ba3f46765fcbb5cc6aca0d95d70b1 100644 (file)
@@ -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;
 }