diff options
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/rangeobject.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c index 0fe119c..c8b10eb 100644 --- a/Objects/rangeobject.c +++ b/Objects/rangeobject.c @@ -354,7 +354,10 @@ static PyObject * rangeiter_next(rangeiterobject *r) { if (r->index < r->len) - return PyLong_FromLong(r->start + (r->index++) * r->step); + /* cast to unsigned to avoid possible signed overflow + in intermediate calculations. */ + return PyLong_FromLong((long)(r->start + + (unsigned long)(r->index++) * r->step)); return NULL; } |