summaryrefslogtreecommitdiff
path: root/numpy/core/src
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2018-01-26 16:12:58 +0100
committerSebastian Berg <sebastian@sipsolutions.net>2018-01-26 22:54:02 +0100
commit7f0ec6313a85dc5445e8d46f41fa17f5e3855582 (patch)
treeb3bf35a374feb2c20bd3cbfe087d77c01abd97c4 /numpy/core/src
parent99019107cbde06294a356fd7fc859f9b31f87410 (diff)
downloadnumpy-7f0ec6313a85dc5445e8d46f41fa17f5e3855582.tar.gz
BUG: Add missing DECREF in Py2 int() cast
The Long number is downcast to int if possible, so the old version has to be DECREF'ed. Thanks to Johannes Barthelmes for bisecting the offending commit. Closes gh-10474
Diffstat (limited to 'numpy/core/src')
-rw-r--r--numpy/core/src/umath/scalarmath.c.src6
1 files changed, 5 insertions, 1 deletions
diff --git a/numpy/core/src/umath/scalarmath.c.src b/numpy/core/src/umath/scalarmath.c.src
index 3b23151f1..7b424cc74 100644
--- a/numpy/core/src/umath/scalarmath.c.src
+++ b/numpy/core/src/umath/scalarmath.c.src
@@ -1424,7 +1424,11 @@ static PyObject *
#ifndef NPY_PY3K
/* Invoke long.__int__ to try to downcast */
- long_result = Py_TYPE(long_result)->tp_as_number->nb_int(long_result);
+ {
+ PyObject *before_downcast = long_result;
+ long_result = Py_TYPE(long_result)->tp_as_number->nb_int(long_result);
+ Py_DECREF(before_downcast);
+ }
#endif
return long_result;