[Python-checkins] bpo-31579: Fixed a possible leak in enumerate() with large indices. (#3753)
Serhiy Storchaka
webhook-mailer at python.org
Tue Sep 26 01:15:01 EDT 2017
https://github.com/python/cpython/commit/0e950dd22b075b4809c84afda8aede02b76ac0fa
commit: 0e950dd22b075b4809c84afda8aede02b76ac0fa
branch: master
author: Serhiy Storchaka <storchaka at gmail.com>
committer: GitHub <noreply at github.com>
date: 2017-09-26T08:14:58+03:00
summary:
bpo-31579: Fixed a possible leak in enumerate() with large indices. (#3753)
files:
M Objects/enumobject.c
diff --git a/Objects/enumobject.c b/Objects/enumobject.c
index 154d901e86d..4d0af14008b 100644
--- a/Objects/enumobject.c
+++ b/Objects/enumobject.c
@@ -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) {
More information about the Python-checkins
mailing list