summaryrefslogtreecommitdiffstats
path: root/Objects/rangeobject.c
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-11-15 12:56:08 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2009-11-15 12:56:08 (GMT)
commitb43dbc26f9abbd6bf96bd95e6701719575c57341 (patch)
tree16409c39e67e51e3bb9891b67af0e62cba4ae2a9 /Objects/rangeobject.c
parentf4817e59299dde54d219d2f4983bb1945a5d1f5e (diff)
downloadcpython-b43dbc26f9abbd6bf96bd95e6701719575c57341.zip
cpython-b43dbc26f9abbd6bf96bd95e6701719575c57341.tar.gz
cpython-b43dbc26f9abbd6bf96bd95e6701719575c57341.tar.bz2
Fix another case of potential signed overflow.
Diffstat (limited to 'Objects/rangeobject.c')
-rw-r--r--Objects/rangeobject.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c
index cabe785..ec75c8f 100644
--- a/Objects/rangeobject.c
+++ b/Objects/rangeobject.c
@@ -411,7 +411,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;
}