Mercurial > cpython-lru_cache-weakref
diff Objects/rangeobject.c @ 57267:3ebf907db028
Fix another case of potential signed overflow.
| author | Mark Dickinson <dickinsm@gmail.com> |
|---|---|
| date | Sun, 15 Nov 2009 12:56:08 +0000 |
| parents | 2aa62fce0bf8 |
| children | eb235eb45d32 |
line wrap: on
line diff
--- a/Objects/rangeobject.c Sun Nov 15 12:34:44 2009 +0000 +++ b/Objects/rangeobject.c Sun Nov 15 12:56:08 2009 +0000 @@ -411,7 +411,10 @@ 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; }
