summaryrefslogtreecommitdiff
path: root/numpy/core/src
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2022-06-08 09:52:14 -0600
committerGitHub <noreply@github.com>2022-06-08 09:52:14 -0600
commite05e65718b34aea0c3be393459e2d5933ab075e0 (patch)
tree47bcde37c1f781815f942bd8cddf1e902280a551 /numpy/core/src
parent1b7ad60e0f8d94fcb7294fb9bf8b12fa75cb43a8 (diff)
parent703a6fa6ac7f5049bb17726a1ba93f7835bf92ae (diff)
downloadnumpy-e05e65718b34aea0c3be393459e2d5933ab075e0.tar.gz
Merge pull request #21690 from seberg/fix-21673
BUG: Prevent attempted broadcasting of 0-D output operands in ufuncs
Diffstat (limited to 'numpy/core/src')
-rw-r--r--numpy/core/src/umath/ufunc_object.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/numpy/core/src/umath/ufunc_object.c b/numpy/core/src/umath/ufunc_object.c
index 290ed24a6..fce7d61de 100644
--- a/numpy/core/src/umath/ufunc_object.c
+++ b/numpy/core/src/umath/ufunc_object.c
@@ -1243,7 +1243,7 @@ try_trivial_single_output_loop(PyArrayMethod_Context *context,
int op_ndim = PyArray_NDIM(op[iop]);
/* Special case 0-D since we can handle broadcasting using a 0-stride */
- if (op_ndim == 0) {
+ if (op_ndim == 0 && iop < nin) {
fixed_strides[iop] = 0;
continue;
}
@@ -1254,7 +1254,7 @@ try_trivial_single_output_loop(PyArrayMethod_Context *context,
operation_shape = PyArray_SHAPE(op[iop]);
}
else if (op_ndim != operation_ndim) {
- return -2; /* dimension mismatch (except 0-d ops) */
+ return -2; /* dimension mismatch (except 0-d input ops) */
}
else if (!PyArray_CompareLists(
operation_shape, PyArray_DIMS(op[iop]), op_ndim)) {