summaryrefslogtreecommitdiffstats
path: root/Objects/enumobject.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2007-02-08 00:07:32 (GMT)
committerRaymond Hettinger <python@rcn.com>2007-02-08 00:07:32 (GMT)
commit6d121f168cca9df59fe4b3908cecbc346e185650 (patch)
treefe8629589e827fe1f8803b5fb90d871e017c7bff /Objects/enumobject.c
parentde33c62466c688d0769744a7503d8e969bce5741 (diff)
downloadcpython-6d121f168cca9df59fe4b3908cecbc346e185650.zip
cpython-6d121f168cca9df59fe4b3908cecbc346e185650.tar.gz
cpython-6d121f168cca9df59fe4b3908cecbc346e185650.tar.bz2
Do not let overflows in enumerate() and count() pass silently.
Diffstat (limited to 'Objects/enumobject.c')
-rw-r--r--Objects/enumobject.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Objects/enumobject.c b/Objects/enumobject.c
index a8f43e0..a456c9d 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;