Skip to content

Commit

Permalink
BUG: ufunc.at segfaults with non-trivial signature
Browse files Browse the repository at this point in the history
Calling the method `at` of a ufunc with non-trivial signature can lead
to a segfault if all checks on the shape, number of arguments, etc, pass
and the actual computation is attempted, e.g. for the ufunc `matmul`.
Now, using `at` with a non-trivial signature will raise a TypeError
analogously the method `outer`.
  • Loading branch information
Dominik Beutel committed Apr 6, 2022
1 parent aeb39df commit 6db8d96
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions numpy/core/src/umath/ufunc_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -5888,6 +5888,13 @@ ufunc_at(PyUFuncObject *ufunc, PyObject *args)

NPY_BEGIN_THREADS_DEF;

if (ufunc->core_enabled) {
PyErr_Format(PyExc_TypeError,
"method at is not allowed in ufunc with non-trivial"\
" signature");
return NULL;
}

if (ufunc->nin > 2) {
PyErr_SetString(PyExc_ValueError,
"Only unary and binary ufuncs supported at this time");
Expand Down

0 comments on commit 6db8d96

Please sign in to comment.