mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #16060: Fix a double DECREF in int() implementation. Thanks Serhiy Storchaka.
This commit is contained in:
parent
3658cb3012
commit
7c95bb35e4
3 changed files with 18 additions and 4 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue