diff options
author | Matti Picus <matti.picus@gmail.com> | 2019-12-03 14:39:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-03 14:39:44 +0200 |
commit | e39aa70e47313e33afd80e3080b135144ed32be8 (patch) | |
tree | 7c3c930280653f0b67a74aedea7530b6999674d6 | |
parent | b03fab8dad4a165e25739f2081e3936b522554ac (diff) | |
parent | de6e644b1853f595683cfbedb3745b24c75ce63d (diff) | |
download | numpy-e39aa70e47313e33afd80e3080b135144ed32be8.tar.gz |
Merge pull request #15036 from eric-wieser/fix-leak
BUG: Fix refcounting in ufunc object loops
-rw-r--r-- | numpy/core/src/umath/loops.c.src | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/numpy/core/src/umath/loops.c.src b/numpy/core/src/umath/loops.c.src index 32aac3ff7..8a2e5bc40 100644 --- a/numpy/core/src/umath/loops.c.src +++ b/numpy/core/src/umath/loops.c.src @@ -235,7 +235,11 @@ PyUFunc_O_O_method(char **args, npy_intp *dimensions, npy_intp *steps, void *fun PyObject **out = (PyObject **)op1; PyObject *ret, *func; func = PyObject_GetAttrString(in1 ? in1 : Py_None, meth); - if (func == NULL || !PyCallable_Check(func)) { + if (func != NULL && !PyCallable_Check(func)) { + Py_DECREF(func); + func = NULL; + } + if (func == NULL) { PyObject *exc, *val, *tb; PyTypeObject *type = in1 ? Py_TYPE(in1) : Py_TYPE(Py_None); PyErr_Fetch(&exc, &val, &tb); |