[Python-checkins] cpython (merge 3.2 -> default): Merge #12973 itertools fix.
mark.dickinson
python-checkins at python.org
Sat Sep 24 10:00:35 CEST 2011
http://hg.python.org/cpython/rev/18eec56bcf29
changeset: 72460:18eec56bcf29
parent: 72458:493886a640b6
parent: 72459:b378864d8ff3
user: Mark Dickinson <mdickinson at enthought.com>
date: Sat Sep 24 08:57:00 2011 +0100
summary:
Merge #12973 itertools fix.
files:
Misc/NEWS | 6 +++---
Modules/itertoolsmodule.c | 4 +++-
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -17,9 +17,9 @@
- 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
--- a/Modules/itertoolsmodule.c
+++ b/Modules/itertoolsmodule.c
@@ -1234,7 +1234,9 @@
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;
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list