diff options
author | Benjamin Peterson <benjamin@python.org> | 2015-02-02 01:59:00 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2015-02-02 01:59:00 (GMT) |
commit | 4b40eeb33901c3a520ce78ae88eb5ee06870130f (patch) | |
tree | e341d3e92baecda546e00b8591d835f59c6c2db5 /Modules/itertoolsmodule.c | |
parent | 68389eaa3f9cbba8654e0121d4787e5099babd77 (diff) | |
download | cpython-4b40eeb33901c3a520ce78ae88eb5ee06870130f.zip cpython-4b40eeb33901c3a520ce78ae88eb5ee06870130f.tar.gz cpython-4b40eeb33901c3a520ce78ae88eb5ee06870130f.tar.bz2 |
detect overflow in combinations (closes #23366)
Diffstat (limited to 'Modules/itertoolsmodule.c')
-rw-r--r-- | Modules/itertoolsmodule.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c index 0123181..5805143 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -2326,6 +2326,10 @@ combinations_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(); |