Skip to content

Commit b43dbc2

Browse files
committed
Fix another case of potential signed overflow.
1 parent f4817e5 commit b43dbc2

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Objects/rangeobject.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,10 @@ static PyObject *
411411
rangeiter_next(rangeiterobject *r)
412412
{
413413
if (r->index < r->len)
414-
return PyLong_FromLong(r->start + (r->index++) * r->step);
414+
/* cast to unsigned to avoid possible signed overflow
415+
in intermediate calculations. */
416+
return PyLong_FromLong((long)(r->start +
417+
(unsigned long)(r->index++) * r->step));
415418
return NULL;
416419
}
417420

0 commit comments

Comments
 (0)