8000 BUG: fix wrong ndim used in empty where check by juliantaylor · Pull Request #9310 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: fix wrong ndim used in empty where check #9310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
8000 Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion numpy/core/src/multiarray/item_selection.c
Original file line number Diff line number Diff line change
Expand Up @@ -2330,7 +2330,7 @@ PyArray_Nonzero(PyArrayObject *self)
return NULL;
}

for (i = 0; i < ndim; ++i) {
for (i = 0; i < PyArray_NDIM(ret); ++i) {
if (PyArray_DIMS(ret)[i] == 0) {
is_empty = 1;
break;
Expand Down
11 changes: 11 additions & 0 deletions numpy/core/tests/test_multiarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -6620,6 +6620,17 @@ def test_empty_result(self):
assert_array_equal(ibad,
np.atleast_2d(np.array([[],[]], dtype=np.intp)))

def test_largedim(self):
# invalid read regression gh-9304
shape = [10, 2, 3, 4, 5, 6]
np.random.seed(2)
array = np.random.rand(*shape)

for i in range(10):
benchmark = array.nonzero()
result = array.nonzero()
assert_array_equal(benchmark, result)


if not IS_PYPY:
# sys.getsizeof() is not valid on PyPy
Expand Down
0