summaryrefslogtreecommitdiffstats
path: root/Modules/itertoolsmodule.c
diff options
context:
space:
mode:
authorMark Dickinson <mdickinson@enthought.com>2011-09-24 07:57:00 (GMT)
committerMark Dickinson <mdickinson@enthought.com>2011-09-24 07:57:00 (GMT)
commita61b053e611dd97258231913b79fafe0a9a16125 (patch)
treea5112e5cb15610424f8465ec4a9a30d6c5163e83 /Modules/itertoolsmodule.c
parent3454d524344bf8a0cbe5178ef299e52fcbc0dc84 (diff)
parentb2f6bc72a269a0c4ed389ad232b47e2a42b8dde0 (diff)
downloadcpython-a61b053e611dd97258231913b79fafe0a9a16125.zip
cpython-a61b053e611dd97258231913b79fafe0a9a16125.tar.gz
cpython-a61b053e611dd97258231913b79fafe0a9a16125.tar.bz2
Merge #12973 itertools fix.
Diffstat (limited to 'Modules/itertoolsmodule.c')
-rw-r--r--Modules/itertoolsmodule.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c
index ad22ec7..d0897c3 100644
--- a/Modules/itertoolsmodule.c
+++ b/Modules/itertoolsmodule.c
@@ -1234,7 +1234,9 @@ islice_next(isliceobject *lz)
return NULL;
lz->cnt++;
oldnext = lz->next;
- lz->next += lz->step;
+ /* The (size_t) cast below avoids the danger of undefined
+ behaviour from signed integer overflow. */
+ lz->next += (size_t)lz->step;
if (lz->next < oldnext || (stop != -1 && lz->next > stop))
lz->next = stop;
return item;