diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2009-11-15 12:56:59 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2009-11-15 12:56:59 (GMT) |
commit | d340f6cd3f8b9417e8ff15a2adcada959878246c (patch) | |
tree | 9b59b2f87f7b6054739cd2f15d102c2d8b05c33c /Objects | |
parent | b6447512ab853a92ff52a19c357fd354800ff638 (diff) | |
download | cpython-d340f6cd3f8b9417e8ff15a2adcada959878246c.zip cpython-d340f6cd3f8b9417e8ff15a2adcada959878246c.tar.gz cpython-d340f6cd3f8b9417e8ff15a2adcada959878246c.tar.bz2 |
Merged revisions 76298 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r76298 | mark.dickinson | 2009-11-15 12:56:08 +0000 (Sun, 15 Nov 2009) | 1 line
Fix another case of potential signed overflow.
........
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; } |