From da4be54bc73f805fa94cc2cd770fecb095c5dac6 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Mon, 6 Feb 2017 21:51:46 +0100 Subject: BUG: core: fix refcount errors on error handling --- numpy/core/src/multiarray/mapping.c | 1 - numpy/core/src/umath/reduction.c | 1 + numpy/core/src/umath/ufunc_object.c | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/numpy/core/src/multiarray/mapping.c b/numpy/core/src/multiarray/mapping.c index a6d1527d8..28c790ae2 100644 --- a/numpy/core/src/multiarray/mapping.c +++ b/numpy/core/src/multiarray/mapping.c @@ -3205,7 +3205,6 @@ PyArray_MapIterArrayCopyIfOverlap(PyArrayObject * a, PyObject * index, Py_INCREF(a); if (PyArray_SetUpdateIfCopyBase(a_copy, a) < 0) { - Py_DECREF(a); goto fail; } diff --git a/numpy/core/src/umath/reduction.c b/numpy/core/src/umath/reduction.c index c7bca1932..47598bed9 100644 --- a/numpy/core/src/umath/reduction.c +++ b/numpy/core/src/umath/reduction.c @@ -189,6 +189,7 @@ conform_reduce_result(int ndim, npy_bool *axis_flags, Py_INCREF(ret); if (PyArray_SetUpdateIfCopyBase(ret_copy, (PyArrayObject *)ret) < 0) { Py_DECREF(ret); + Py_DECREF(ret_copy); return NULL; } diff --git a/numpy/core/src/umath/ufunc_object.c b/numpy/core/src/umath/ufunc_object.c index 91bb44435..a07b2514e 100644 --- a/numpy/core/src/umath/ufunc_object.c +++ b/numpy/core/src/umath/ufunc_object.c @@ -1484,6 +1484,7 @@ iterator_loop(PyUFuncObject *ufunc, /* Call the __array_prepare__ functions for the new array */ if (prepare_ufunc_output(ufunc, &op[nin+i], arr_prep[i], arr_prep_args, i) < 0) { + NpyIter_Deallocate(iter); return -1; } -- cgit v1.2.1