Kaydet (Commit) 0cc5a2b2 authored tarafından Serhiy Storchaka's avatar Serhiy Storchaka

Fixed integer overflow and handled MemoryError in array.buffer_info().

üst aaa4baf4
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment