mirror of
https://github.com/python/cpython.git
synced 2025-10-07 15:42:02 +00:00
bpo-31579: Fixed a possible leak in enumerate() with large indices. (#3753)
This commit is contained in:
parent
4a2d00cb45
commit
0e950dd22b
1 changed files with 6 additions and 2 deletions
|
@ -108,14 +108,18 @@ enum_next_long(enumobject *en, PyObject* next_item)
|
|||
|
||||
if (en->en_longindex == NULL) {
|
||||
en->en_longindex = PyLong_FromSsize_t(PY_SSIZE_T_MAX);
|
||||
if (en->en_longindex == NULL)
|
||||
if (en->en_longindex == NULL) {
|
||||
Py_DECREF(next_item);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
next_index = en->en_longindex;
|
||||
assert(next_index != NULL);
|
||||
stepped_up = PyNumber_Add(next_index, _PyLong_One);
|
||||
if (stepped_up == NULL)
|
||||
if (stepped_up == NULL) {
|
||||
Py_DECREF(next_item);
|
||||
return NULL;
|
||||
}
|
||||
en->en_longindex = stepped_up;
|
||||
|
||||
if (result->ob_refcnt == 1) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue