diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2019-06-29 00:37:35 -0700 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2019-06-29 09:43:22 +0200 |
commit | 68e51613e90311d6b962cc0881e17f28c0fd878f (patch) | |
tree | fcc586769d8426c8940992491d5fa9735ba5a1cb | |
parent | f8cd55f2c34ab78d124ded071ee10245264bc097 (diff) | |
download | cython-68e51613e90311d6b962cc0881e17f28c0fd878f.tar.gz |
BUG: Fix reference count issues (GH-3022)
-rw-r--r-- | Cython/Utility/Optimize.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Cython/Utility/Optimize.c b/Cython/Utility/Optimize.c index 22d163461..d6c32ace2 100644 --- a/Cython/Utility/Optimize.c +++ b/Cython/Utility/Optimize.c @@ -685,9 +685,11 @@ static PyObject* __Pyx__PyNumber_PowerOf2(PyObject *two, PyObject *exp, PyObject return PyLong_FromUnsignedLongLong(value); #endif } else { - PyObject *one = PyInt_FromLong(1L); + PyObject *result, *one = PyInt_FromLong(1L); if (unlikely(!one)) return NULL; - return PyNumber_Lshift(one, exp); + result = PyNumber_Lshift(one, exp); + Py_DECREF(one); + return result; } } else if (shiftby == -1 && PyErr_Occurred()) { PyErr_Clear(); |