summaryrefslogtreecommitdiffstats
path: root/Objects/abstract.c
diff options
context:
space:
mode:
authorMark Dickinson <mdickinson@enthought.com>2012-09-27 18:38:59 (GMT)
committerMark Dickinson <mdickinson@enthought.com>2012-09-27 18:38:59 (GMT)
commit3d7838593bb7b196e39f93eb6457ff9ef2ffbb5a (patch)
tree32f2061b50d07a5954a48b2a271355db5c7faaa9 /Objects/abstract.c
parent0beb4d28d01759a95ea4de5ff77dff537de718ef (diff)
downloadcpython-3d7838593bb7b196e39f93eb6457ff9ef2ffbb5a.zip
cpython-3d7838593bb7b196e39f93eb6457ff9ef2ffbb5a.tar.gz
cpython-3d7838593bb7b196e39f93eb6457ff9ef2ffbb5a.tar.bz2
Issue #16060: Fix a double DECREF in int() implementation. Thanks Serhiy Storchaka.
Diffstat (limited to 'Objects/abstract.c')
-rw-r--r--Objects/abstract.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index ed5e196..a2737dd 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -1228,11 +1228,10 @@ convert_integral_to_int(PyObject *integral, const char *error_format)
nb = Py_TYPE(integral)->tp_as_number;
if (nb->nb_int) {
PyObject *as_int = nb->nb_int(integral);
- Py_DECREF(integral);
- if (!as_int)
- return NULL;
- if (PyLong_Check(as_int))
+ if (!as_int || PyLong_Check(as_int)) {
+ Py_DECREF(integral);
return as_int;
+ }
Py_DECREF(as_int);
}
PyErr_Format(PyExc_TypeError, error_format, Py_TYPE(integral)->tp_name);