Commit 5ba19402 authored by Dag Sverre Seljebotn's avatar Dag Sverre Seljebotn

Buffer: Always do item size check

parent e6f23c31
......@@ -670,6 +670,11 @@ def get_getbuffer_code(dtype, code):
__Pyx_BufferNdimError(buf, nd);
goto fail;
}
if (buf->itemsize != sizeof(%(dtype_cname)s)) {
PyErr_SetString(PyExc_ValueError,
"Item size of buffer does not match size of %(dtype)s.");
goto fail;
}
if (!cast) {
ts = buf->format;
ts = __Pyx_ConsumeWhitespace(ts);
......@@ -684,12 +689,6 @@ def get_getbuffer_code(dtype, code):
__Pyx_DescribeTokenInFormatString(ts));
goto fail;
}
} else {
if (buf->itemsize != sizeof(%(dtype_cname)s)) {
PyErr_SetString(PyExc_ValueError,
"Attempted cast of buffer to datatype of different size.");
goto fail;
}
}
if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones;
return 0;
......
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