summaryrefslogtreecommitdiffstats
path: root/Modules/itertoolsmodule.c
diff options
context:
space:
mode:
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;