diff options
author | Mark Dickinson <mdickinson@enthought.com> | 2012-10-06 18:04:49 +0100 |
---|---|---|
committer | Mark Dickinson <mdickinson@enthought.com> | 2012-10-06 18:04:49 +0100 |
commit | c04ddff290fc203d05b75c8569b748525fb76b5b (patch) | |
tree | 184849e76ebe965016c2737939f9eaa0dfb900ee /Modules/audioop.c | |
parent | a2028733ef072740921017e544d29d191fdb2c9c (diff) | |
download | cpython-git-c04ddff290fc203d05b75c8569b748525fb76b5b.tar.gz |
Issue #16096: Fix several occurrences of potential signed integer overflow. Thanks Serhiy Storchaka.
Diffstat (limited to 'Modules/audioop.c')
-rw-r--r-- | Modules/audioop.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Modules/audioop.c b/Modules/audioop.c index 0375e4e625..2bca391b5a 100644 --- a/Modules/audioop.c +++ b/Modules/audioop.c @@ -1108,8 +1108,7 @@ audioop_ratecv(PyObject *self, PyObject *args) PyErr_SetString(AudioopError, "# of channels should be >= 1"); return NULL; } - bytes_per_frame = size * nchannels; - if (bytes_per_frame / nchannels != size) { + if (size > INT_MAX / nchannels) { /* This overflow test is rigorously correct because both multiplicands are >= 1. Use the argument names from the docs for the error msg. */ @@ -1117,6 +1116,7 @@ audioop_ratecv(PyObject *self, PyObject *args) "width * nchannels too big for a C int"); return NULL; } + bytes_per_frame = size * nchannels; if (weightA < 1 || weightB < 0) { PyErr_SetString(AudioopError, "weightA should be >= 1, weightB should be >= 0"); |