From 7254dd7da0ce26f83b667dcff1fb3b545fb47899 Mon Sep 17 00:00:00 2001 From: Stefan van der Walt Date: Sun, 18 Nov 2007 20:49:47 +0000 Subject: Fix indexing with booleans (patch by Achim Gaedke). Closes #614. --- numpy/core/src/arrayobject.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'numpy/core/src/arrayobject.c') diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c index 2847b7796..e84ba56fc 100644 --- a/numpy/core/src/arrayobject.c +++ b/numpy/core/src/arrayobject.c @@ -9336,7 +9336,14 @@ iter_ass_sub_Bool(PyArrayIterObject *self, PyArrayObject *ind, "boolean index array should have 1 dimension"); return -1; } + index = ind->dimensions[0]; + if (index > self->size) { + PyErr_SetString(PyExc_ValueError, + "boolean index array has too many values"); + return -1; + } + strides = ind->strides[0]; dptr = ind->data; PyArray_ITER_RESET(self); -- cgit v1.2.1