Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cf26fc9

Browse files
committed
BUG: prevent nonzero memchr from running out of bounds
1 parent 60b5dfe commit cf26fc9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

numpy/core/src/multiarray/item_selection.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2472,7 +2472,8 @@ PyArray_Nonzero(PyArrayObject *self)
24722472
npy_intp subsize;
24732473
npy_intp j = 0;
24742474
while (1) {
2475-
npy_memchr(data + j * stride, 0, stride, count, &subsize, 1);
2475+
npy_memchr(data + j * stride, 0, stride, count - j,
2476+
&subsize, 1);
24762477
j += subsize;
24772478
if (j >= count) {
24782479
break;

0 commit comments

Comments
 (0)