summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatti Picus <matti.picus@gmail.com>2019-12-03 14:39:44 +0200
committerGitHub <noreply@github.com>2019-12-03 14:39:44 +0200
commite39aa70e47313e33afd80e3080b135144ed32be8 (patch)
tree7c3c930280653f0b67a74aedea7530b6999674d6
parentb03fab8dad4a165e25739f2081e3936b522554ac (diff)
parentde6e644b1853f595683cfbedb3745b24c75ce63d (diff)
downloadnumpy-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.src6
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);