diff options
| author | Sebastian Berg <sebastian@sipsolutions.net> | 2012-10-30 18:57:54 +0100 |
|---|---|---|
| committer | Sebastian Berg <sebastian@sipsolutions.net> | 2013-04-12 16:44:59 +0200 |
| commit | a35a7af4160b1ca8f1744ebeee34f1c0ac0125da (patch) | |
| tree | 87b954a127bfe8da98a45f9faeb3711fdb266b61 /numpy | |
| parent | 18ee645bf53185ff4f00ad91861356f2eb1222a0 (diff) | |
| download | numpy-a35a7af4160b1ca8f1744ebeee34f1c0ac0125da.tar.gz | |
BUG: Check for maximum dimension for fancy indexing.
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/core/src/multiarray/mapping.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/mapping.c b/numpy/core/src/multiarray/mapping.c index 9c25a1019..cc9a55bee 100644 --- a/numpy/core/src/multiarray/mapping.c +++ b/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]; } |
