Commit de3cdbbe authored by Mark Florisson's avatar Mark Florisson

Don't allow more dimensions than buffer_max_dims

parent 1ad72710
......@@ -2644,6 +2644,11 @@ class IndexNode(ExprNode):
self.index = None
self.is_temp = True
self.use_managed_ref = True
if not MemoryView.validate_axes(self.pos, axes):
self.type = error_type
return
self.type = PyrexTypes.MemoryViewSliceType(
self.base.type.dtype, axes)
......
......@@ -723,6 +723,14 @@ def get_axes_specs(env, axes):
return axes_specs
def validate_axes(pos, axes):
if len(axes) >= Options.buffer_max_dims:
error(pos, "More dimensions than the maximum number"
" of buffer dimensions were used.")
return False
return True
def all(it):
for item in it:
if not item:
......
......@@ -883,10 +883,13 @@ class MemoryViewSliceTypeNode(CBaseTypeNode):
self.type = PyrexTypes.ErrorType()
return self.type
if not MemoryView.validate_axes(self.pos, axes_specs):
self.type = error_type
else:
MemoryView.validate_memslice_dtype(self.pos, base_type)
self.type = PyrexTypes.MemoryViewSliceType(base_type, axes_specs)
self.use_memview_utilities(env)
return self.type
def use_memview_utilities(self, env):
......
......@@ -54,8 +54,15 @@ cdef struct Invalid:
cdef Valid[:] validslice
cdef Invalid[:] invalidslice
cdef int[:, :, :, :] four_D
four_D[None, None, None, None]
four_D[None, None, None, None, None]
cdef int[:, :, :, :, :, :, :, :] eight_D = object()
# These are VALID
cdef int[::view.indirect_contiguous, ::view.contiguous] a9
four_D[None, None, None]
_ERRORS = u'''
11:25: Cannot specify an array that is both C and Fortran contiguous.
......@@ -79,4 +86,7 @@ _ERRORS = u'''
46:35: Can only create cython.array from pointer or array
47:24: Cannot assign type 'double' to 'Py_ssize_t'
55:13: Invalid base type for memoryview slice: Invalid
58:6: More dimensions than the maximum number of buffer dimensions were used.
59:6: More dimensions than the maximum number of buffer dimensions were used.
61:9: More dimensions than the maximum number of buffer dimensions were used.
'''
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