[Python-checkins] cpython: Issue #16060: Fix a double DECREF in int() implementation. Thanks Serhiy
georg.brandl
python-checkins at python.org
Sat Sep 29 09:27:45 CEST 2012
http://hg.python.org/cpython/rev/d23eb81bd482
changeset: 79232:d23eb81bd482
user: Mark Dickinson <mdickinson at enthought.com>
date: Thu Sep 27 19:38:59 2012 +0100
summary:
Issue #16060: Fix a double DECREF in int() implementation. Thanks Serhiy Storchaka.
files:
Misc/NEWS | 3 +++
Objects/abstract.c | 7 +++----
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@
- Issue #16046: Fix loading sourceless legacy .pyo files.
+- Issue #16060: Fix refcounting bug when __trunc__ returns an object
+ whose __int__ gives a non-integer. Patch by Serhiy Storchaka.
+
Library
-------
diff --git a/Objects/abstract.c b/Objects/abstract.c
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -1228,11 +1228,10 @@
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);
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list