Commit dee74313 authored by David Gobbi's avatar David Gobbi
Browse files

BUG 12730: Fix issue with large buffer objects in python wrappers.

Change-Id: I29a3dc3d942eab89453a433692899a66fdf7d4a3
parent be64234e
......@@ -190,9 +190,11 @@ bool vtkPythonGetValue(PyObject *o, const void *&a)
if (b->bf_getsegcount(o, NULL) == 1)
{
void *p;
int s = (int)b->bf_getreadbuffer(o, 0, &p);
if (s >= 0)
Py_ssize_t sz = b->bf_getreadbuffer(o, 0, &p);
if (sz >= 0 && sz <= VTK_INT_MAX)
{
// check for pointer mangled as string
int s = (int)sz;
a = vtkPythonUtil::UnmanglePointer((char *)p, &s, "void_p");
if (s >= 0)
{
......@@ -209,6 +211,12 @@ bool vtkPythonGetValue(PyObject *o, const void *&a)
PyErr_SetString(PyExc_TypeError, "cannot get a void pointer");
}
}
else if (sz >= 0)
{
// directly use the pointer to the buffer contents
a = p;
return true;
}
return false;
}
PyErr_SetString(PyExc_TypeError, "buffer must be single-segment");
......
Supports Markdown
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