Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
bpo-31579: Fixed a possible leak in enumerate() with large indices.
  • Loading branch information
serhiy-storchaka committed Sep 25, 2017
commit 01075c6f15d31a54366781509a173e66a83e1853
8 changes: 6 additions & 2 deletions Objects/enumobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down