Merge #12973 itertools fix.

This commit is contained in:
Mark Dickinson 2011-09-24 08:57:00 +01:00
commit a61b053e61
2 changed files with 6 additions and 4 deletions

View File

@ -17,9 +17,9 @@ Core and Builtins
- Issue #13021: Missing decref on an error path. Thanks to Suman Saha for
finding the bug and providing a patch.
- Issue #12973: Fix overflow check that relied on undefined behaviour in
list_repeat. This bug caused test_list to fail with recent versions
of Clang.
- Issue #12973: Fix overflow checks that relied on undefined behaviour in
list_repeat (listobject.c) and islice_next (itertoolsmodule.c). These bugs
caused test failures with recent versions of Clang.
- Issue #12904: os.utime, os.futimes, os.lutimes, and os.futimesat now write
atime and mtime with nanosecond precision on modern POSIX platforms.

View File

@ -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;