8000 BUG: Ufunc reduce reference leak (backport) by mhvk · Pull Request #10200 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: Ufunc reduce reference leak (backport) #10200

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 2 commits into from
Dec 11, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
BUG: Failure to DECREF in PyUFunc_GenericReduction.
Would lead to a reference leak for the case that an invalid axis
is passed in.
  • Loading branch information
mhvk committed Dec 11, 2017
commit 87faab201264ba8df65fad8d9439a0854caa3f3e
6 changes: 4 additions & 2 deletions numpy/core/src/umath/ufunc_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -1751,7 +1751,7 @@ make_arr_prep_args(npy_intp nin, PyObject *args, PyObject *kwds)
/*
* Validate the core dimensions of all the operands, and collect all of
* the labelled core dimensions into 'core_dim_sizes'.
*
*
* Returns 0 on success, and -1 on failure
*
* The behavior has been changed in NumPy 1.10.0, and the following
Expand Down Expand Up @@ -3707,7 +3707,7 @@ PyUFunc_GenericReduction(PyUFuncObject *ufunc, PyObject *args,
PyDict_SetItem(kwds, npy_um_str_out, out_obj);
}
}

if (operation == UFUNC_REDUCEAT) {
PyArray_Descr *indtype;
indtype = PyArray_DescrFromType(NPY_INTP);
Expand Down Expand Up @@ -3827,6 +3827,8 @@ PyUFunc_GenericReduction(PyUFuncObject *ufunc, PyObject *args,
axis = 0;
}
else if (check_and_adjust_axis(&axis, ndim) < 0) {
Py_XDECREF(otype);
Py_DECREF(mp);
return NULL;
}
axes[0] = (int)axis;
Expand Down
0