diff options
author | Benjamin Peterson <benjamin@python.org> | 2015-02-02 02:11:39 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2015-02-02 02:11:39 (GMT) |
commit | f635dc32b1dc3d322acd281921afdb8c13261838 (patch) | |
tree | 60356caab13853d253743dd8a705504fe0d21e49 | |
parent | 819c4e9bc41abceca28c4f8488244d03c679b8c4 (diff) | |
parent | 6f082297b260d3eb4975d6d4305eba6fd26f9ae9 (diff) | |
download | cpython-f635dc32b1dc3d322acd281921afdb8c13261838.zip cpython-f635dc32b1dc3d322acd281921afdb8c13261838.tar.gz cpython-f635dc32b1dc3d322acd281921afdb8c13261838.tar.bz2 |
merge 3.3 (#23365)
-rw-r--r-- | Lib/test/test_itertools.py | 6 | ||||
-rw-r--r-- | Misc/NEWS | 2 | ||||
-rw-r--r-- | 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 index c5be5e4..1a5c79c 100644 --- a/Lib/test/test_itertools.py +++ b/Lib/test/test_itertools.py @@ -351,8 +351,12 @@ class TestBasicOps(unittest.TestCase): for proto in range(pickle.HIGHEST_PROTOCOL + 1): self.pickletest(proto, cwr(values,r)) # test pickling - # Test implementation detail: tuple re-use + @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 @@ -52,6 +52,8 @@ Library - 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 index b631c35..610799f 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -2704,6 +2704,10 @@ cwr_new(PyTypeObject *type, PyObject *args, PyObject *kwds) 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(); |