diff options
author | Mark Dickinson <mdickinson@enthought.com> | 2011-09-24 08:57:00 +0100 |
---|---|---|
committer | Mark Dickinson <mdickinson@enthought.com> | 2011-09-24 08:57:00 +0100 |
commit | a61b053e611dd97258231913b79fafe0a9a16125 (patch) | |
tree | a5112e5cb15610424f8465ec4a9a30d6c5163e83 | |
parent | 3454d524344bf8a0cbe5178ef299e52fcbc0dc84 (diff) | |
parent | b2f6bc72a269a0c4ed389ad232b47e2a42b8dde0 (diff) | |
download | cpython-git-a61b053e611dd97258231913b79fafe0a9a16125.tar.gz |
Merge #12973 itertools fix.
-rw-r--r-- | Misc/NEWS | 6 | ||||
-rw-r--r-- | Modules/itertoolsmodule.c | 4 |
2 files changed, 6 insertions, 4 deletions
@@ -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. diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c index ad22ec790c..d0897c3eb9 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; |