diff options
| author | Marten van Kerkwijk <mhvk@astro.utoronto.ca> | 2017-12-10 13:52:50 -0500 |
|---|---|---|
| committer | Marten van Kerkwijk <mhvk@astro.utoronto.ca> | 2017-12-10 13:52:50 -0500 |
| commit | 1cb7ffdef69980460c00a60636abbf6b4c470b75 (patch) | |
| tree | d8456fe6b92dc88b2ebecab6c802ba64fbe36b4a | |
| parent | 7b0252c1a49ad8627bb58eb8095541e19aea5239 (diff) | |
| download | numpy-1cb7ffdef69980460c00a60636abbf6b4c470b75.tar.gz | |
BUG: Failure to DECREF in PyUFunc_GenericReduction.
Would lead to a reference leak for the case that an invalid axis
is passed in.
| -rw-r--r-- | numpy/core/src/umath/ufunc_object.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/numpy/core/src/umath/ufunc_object.c b/numpy/core/src/umath/ufunc_object.c index 35c7724b1..e99202756 100644 --- a/numpy/core/src/umath/ufunc_object.c +++ b/numpy/core/src/umath/ufunc_object.c @@ -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 @@ -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); @@ -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; |
