diff options
author | Christian Heimes <christian@python.org> | 2014-01-27 00:12:00 (GMT) |
---|---|---|
committer | Christian Heimes <christian@python.org> | 2014-01-27 00:12:00 (GMT) |
commit | c4ab9a4f1d923bb60a341856da1d273b17a545e0 (patch) | |
tree | 041c081542e3d9929b1cf05a7076bb1cc297de3d /Modules | |
parent | 936e2f36ade1506d56dd5f10e1967936aabe70b3 (diff) | |
download | cpython-c4ab9a4f1d923bb60a341856da1d273b17a545e0.zip cpython-c4ab9a4f1d923bb60a341856da1d273b17a545e0.tar.gz cpython-c4ab9a4f1d923bb60a341856da1d273b17a545e0.tar.bz2 |
Issue #20394: Attempt to silence CID 1164423: Division or modulo by zero in audioop_ratecv_impl()
Serhiy and I had the same idea so it's most likely right. ;)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/audioop.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Modules/audioop.c b/Modules/audioop.c index cc3a020..159b2fb 100644 --- a/Modules/audioop.c +++ b/Modules/audioop.c @@ -1304,6 +1304,7 @@ audioop_ratecv_impl(PyModuleDef *module, Py_buffer *fragment, int width, int nch "weightA should be >= 1, weightB should be >= 0"); return NULL; } + assert(fragment->len >= 0); if (fragment->len % bytes_per_frame != 0) { PyErr_SetString(AudioopError, "not a whole number of frames"); return NULL; @@ -1370,7 +1371,7 @@ audioop_ratecv_impl(PyModuleDef *module, Py_buffer *fragment, int width, int nch case ceiling(len/inrate) * outrate. */ /* compute ceiling(len/inrate) without overflow */ - Py_ssize_t q = len > 0 ? 1 + (len - 1) / inrate : 0; + Py_ssize_t q = 1 + (len - 1) / inrate; if (outrate > PY_SSIZE_T_MAX / q / bytes_per_frame) str = NULL; else |