[issue22939] integer overflow in iterator object
Clement Rouault
report at bugs.python.org
Tue Dec 9 11:46:39 CET 2014
Clement Rouault added the comment:
> Also, PY_SSIZE_T_MAX is a valid value to pass to PySequence_GetItem(), so it shouldn't be blocked unless necessary.
I agree with you, that's why my first path was checking at the next call if it->it_index had overflowed. But then it relies on undefined behaviour.
> I would think that the PY_SSIZE_T_MAX check belongs inside the:
>
> if (result != NULL) {
> it->it_index++;
> return result;
> }
If we raise the OverflowError when it->it_index really overflow (just after the getitem PY_SSIZE_T_MAX).
Is it really necessary to do the overflow check after the GetItem ? because the value returned by `PySequence_GetItem(seq, PY_SSIZE_T_MAX);` will be never used.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22939>
_______________________________________
More information about the Python-bugs-list
mailing list