diff options
author | Raymond Hettinger <python@rcn.com> | 2007-02-07 23:57:05 +0000 |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2007-02-07 23:57:05 +0000 |
commit | 9f0e1ea96402bf6fa72560640777bf8c3bd186fb (patch) | |
tree | 8afe516eec3490fd24da7bdb3a2479ec0688c8ce /Objects/enumobject.c | |
parent | bbe92887ced108cb7ffac2fa037e72981920f21f (diff) | |
download | cpython-git-9f0e1ea96402bf6fa72560640777bf8c3bd186fb.tar.gz |
Do not let overflows in enumerate() and count() pass silently.
Diffstat (limited to 'Objects/enumobject.c')
-rw-r--r-- | Objects/enumobject.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Objects/enumobject.c b/Objects/enumobject.c index a8f43e0738..a456c9dafd 100644 --- a/Objects/enumobject.c +++ b/Objects/enumobject.c @@ -62,6 +62,12 @@ enum_next(enumobject *en) PyObject *result = en->en_result; PyObject *it = en->en_sit; + if (en->en_index == LONG_MAX) { + PyErr_SetString(PyExc_OverflowError, + "enumerate() is limited to LONG_MAX items"); + return NULL; + } + next_item = (*it->ob_type->tp_iternext)(it); if (next_item == NULL) return NULL; |