mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Issue #16096: Fix several occurrences of potential signed integer overflow. Thanks Serhiy Storchaka.
This commit is contained in:
parent
a2028733ef
commit
c04ddff290
7 changed files with 30 additions and 35 deletions
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue