[Python-checkins] cpython: Issue #20394: Attempt to silence CID 1164423: Division or modulo by zero in

christian.heimes python-checkins at python.org
Mon Jan 27 01:12:28 CET 2014


http://hg.python.org/cpython/rev/bf52f2dbfdde
changeset:   88741:bf52f2dbfdde
user:        Christian Heimes <christian at python.org>
date:        Mon Jan 27 01:12:00 2014 +0100
summary:
  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. ;)

files:
  Modules/audioop.c |  3 ++-
  1 files changed, 2 insertions(+), 1 deletions(-)


diff --git a/Modules/audioop.c b/Modules/audioop.c
--- a/Modules/audioop.c
+++ b/Modules/audioop.c
@@ -1304,6 +1304,7 @@
             "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 @@
            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

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list