[issue23366] integer overflow in itertools.combinations
Serhiy Storchaka
report at bugs.python.org
Mon Feb 2 08:05:08 CET 2015
Serhiy Storchaka added the comment:
This commit (and three other) causes compiler warnings:
./Modules/itertoolsmodule.c: In function ‘product_new’:
./Modules/itertoolsmodule.c:2025:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (repeat > PY_SSIZE_T_MAX/sizeof(Py_ssize_t) ||
^
./Modules/itertoolsmodule.c:2026:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
nargs > PY_SSIZE_T_MAX/(repeat * sizeof(Py_ssize_t))) {
^
./Modules/itertoolsmodule.c: In function ‘combinations_new’:
./Modules/itertoolsmodule.c:2371:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (r > PY_SSIZE_T_MAX/sizeof(Py_ssize_t)) {
^
./Modules/itertoolsmodule.c: In function ‘cwr_new’:
./Modules/itertoolsmodule.c:2716:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (r > PY_SSIZE_T_MAX/sizeof(Py_ssize_t)) {
^
./Modules/itertoolsmodule.c: In function ‘permutations_new’:
./Modules/itertoolsmodule.c:3061:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (n > PY_SSIZE_T_MAX/sizeof(Py_ssize_t) ||
^
./Modules/itertoolsmodule.c:3062:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
r > PY_SSIZE_T_MAX/sizeof(Py_ssize_t)) {
^
May be use PyMem_New instead of PyMem_Malloc?
----------
keywords: +patch
nosy: +serhiy.storchaka
status: closed -> open
Added file: http://bugs.python.org/file37974/itertools_overflows.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23366>
_______________________________________
More information about the Python-bugs-list
mailing list