Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

BUG: Check for maximum dimension for fancy indexing.

  • Loading branch information...
commit a35a7af4160b1ca8f1744ebeee34f1c0ac0125da 1 parent 18ee645
@seberg authored
Showing with 10 additions and 1 deletion.
  1. +10 −1 numpy/core/src/multiarray/mapping.c
View
11 numpy/core/src/multiarray/mapping.c
@@ -1864,8 +1864,17 @@ PyArray_MapIterBind(PyArrayMapIterObject *mit, PyArrayObject *arr)
if (mit->subspace == NULL) {
goto fail;
}
- /* Expand dimensions of result */
+
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++) {
mit->dimensions[mit->nd+i] = PyArray_DIMS(mit->subspace->ao)[i];
}
Please sign in to comment.
Something went wrong with that request. Please try again.