Skip to content

Commit

Permalink
BUG: Check for maximum dimension for fancy indexing.
Browse files Browse the repository at this point in the history
  • Loading branch information
seberg committed Apr 12, 2013
1 parent 18ee645 commit a35a7af
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion numpy/core/src/multiarray/mapping.c
Expand Up @@ -1864,8 +1864,17 @@ PyArray_MapIterBind(PyArrayMapIterObject *mit, PyArrayObject *arr)
if (mit->subspace == NULL) { if (mit->subspace == NULL) {
goto fail; goto fail;
} }
/* Expand dimensions of result */
subdim = PyArray_NDIM(mit->subspace->ao); subdim = PyArray_NDIM(mit->subspace->ao);
if (mit->nd + subdim > NPY_MAXDIMS) {
PyErr_Format(PyExc_ValueError,
"number of dimensions must be within [0, %d], "
"indexed array has %d",
NPY_MAXDIMS, mit->nd + subdim);
goto fail;
}

/* Expand dimensions of result */
for (i = 0; i < subdim; i++) { for (i = 0; i < subdim; i++) {
mit->dimensions[mit->nd+i] = PyArray_DIMS(mit->subspace->ao)[i]; mit->dimensions[mit->nd+i] = PyArray_DIMS(mit->subspace->ao)[i];
} }
Expand Down

0 comments on commit a35a7af

Please sign in to comment.