[Python-checkins] cpython (merge 3.4 -> default): merge 3.4 (#23365)
benjamin.peterson
python-checkins at python.org
Mon Feb 2 03:13:51 CET 2015
https://hg.python.org/cpython/rev/4d875a690c01
changeset: 94454:4d875a690c01
parent: 94450:886559229911
parent: 94453:2e7a02e4cf2c
user: Benjamin Peterson <benjamin at python.org>
date: Sun Feb 01 21:11:54 2015 -0500
summary:
merge 3.4 (#23365)
files:
Lib/test/test_itertools.py | 6 +++++-
Misc/NEWS | 2 ++
Modules/itertoolsmodule.c | 4 ++++
3 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py
--- a/Lib/test/test_itertools.py
+++ b/Lib/test/test_itertools.py
@@ -351,8 +351,12 @@
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
self.pickletest(proto, cwr(values,r)) # test pickling
+ @support.bigaddrspacetest
+ def test_combinations_with_replacement_overflow(self):
+ with self.assertRaises(OverflowError):
+ combinations_with_replacement("AA", 2**30)
+
# Test implementation detail: tuple re-use
-
@support.impl_detail("tuple reuse is specific to CPython")
def test_combinations_with_replacement_tuple_reuse(self):
cwr = combinations_with_replacement
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -231,6 +231,8 @@
- Issue #23366: Fixed possible integer overflow in itertools.combinations.
+- Issue #23366: Fixed possible integer overflow in itertools.combinations.
+
- Issue #23369: Fixed possible integer overflow in
_json.encode_basestring_ascii.
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c
--- a/Modules/itertoolsmodule.c
+++ b/Modules/itertoolsmodule.c
@@ -2704,6 +2704,10 @@
goto error;
}
+ if (r > PY_SSIZE_T_MAX/sizeof(Py_ssize_t)) {
+ PyErr_SetString(PyExc_OverflowError, "r is too big");
+ goto error;
+ }
indices = PyMem_Malloc(r * sizeof(Py_ssize_t));
if (indices == NULL) {
PyErr_NoMemory();
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list