diff options
author | Raymond Hettinger <python@rcn.com> | 2007-02-07 23:57:05 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2007-02-07 23:57:05 (GMT) |
commit | 9f0e1ea96402bf6fa72560640777bf8c3bd186fb (patch) | |
tree | 8afe516eec3490fd24da7bdb3a2479ec0688c8ce /Modules/itertoolsmodule.c | |
parent | bbe92887ced108cb7ffac2fa037e72981920f21f (diff) | |
download | cpython-9f0e1ea96402bf6fa72560640777bf8c3bd186fb.zip cpython-9f0e1ea96402bf6fa72560640777bf8c3bd186fb.tar.gz cpython-9f0e1ea96402bf6fa72560640777bf8c3bd186fb.tar.bz2 |
Do not let overflows in enumerate() and count() pass silently.
Diffstat (limited to 'Modules/itertoolsmodule.c')
-rw-r--r-- | Modules/itertoolsmodule.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c index 7896143..70f787f 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -2073,6 +2073,11 @@ count_new(PyTypeObject *type, PyObject *args, PyObject *kwds) static PyObject * count_next(countobject *lz) { + if (lz->cnt == LONG_MAX) { + PyErr_SetString(PyExc_OverflowError, + "cannot count beyond LONG_MAX"); + return NULL; + } return PyInt_FromSsize_t(lz->cnt++); } |