[issue8674] audioop: incorrect integer overflow checks

Mark Dickinson report at bugs.python.org
Mon May 10 16:44:40 CEST 2010


Mark Dickinson <dickinsm at gmail.com> added the comment:

Thanks for the patch.  I agree that undefined behaviour (e.g., from signed overflow) should be avoided where at all possible.

Do you have any Python examples that failed to trigger the overflow on your platform?  If so, it would be useful to add them to Lib/test/test_audioop.py as extra testcases.

One other question:  is there something about the formats that audioop is dealing with that limits sizes to INT_MAX (rather than PY_SSIZE_T_MAX, for example)?  I'm not really familiar with audio formats.

As an aside, I also find it strange that the code raises MemoryError in these cases, since these exceptions can be raised even when there's plenty of memory available.  IMO MemoryError should only be raised as a result of a failed attempt to allocate memory from the system.  Some other exception---perhaps OverflowError---would seem more appropriate here.

----------
nosy: +mark.dickinson

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8674>
_______________________________________


More information about the Python-bugs-list mailing list