shithub: aubio

Download patch

ref: 18e22f9553c239cfbe915cce1998025784e87ed8
parent: bf63c61f22c40b5f0918c00ec82995b43ef1bc09
author: Paul Brossier <piem@piem.org>
date: Tue Dec 10 12:57:30 EST 2013

ext/py-source.c: fix size checks

Signed-off-by: Paul Brossier <piem@piem.org>

--- a/python/ext/py-source.c
+++ b/python/ext/py-source.c
@@ -40,21 +40,21 @@
   }
 
   self->samplerate = 0;
-  if (samplerate > 0) {
+  if ((sint_t)samplerate > 0) {
     self->samplerate = samplerate;
-  //} else if (samplerate < 0) {
-  //  PyErr_SetString (PyExc_ValueError,
-  //      "can not use negative value for samplerate");
-  //  return NULL;
+  } else if ((sint_t)samplerate < 0) {
+    PyErr_SetString (PyExc_ValueError,
+        "can not use negative value for samplerate");
+    return NULL;
   }
 
   self->hop_size = Py_default_vector_length / 2;
-  if (hop_size > 0) {
+  if ((sint_t)hop_size > 0) {
     self->hop_size = hop_size;
-  //} else if (hop_size < 0) {
-  //  PyErr_SetString (PyExc_ValueError,
-  //      "can not use negative value for hop_size");
-  //  return NULL;
+  } else if ((sint_t)hop_size < 0) {
+    PyErr_SetString (PyExc_ValueError,
+        "can not use negative value for hop_size");
+    return NULL;
   }
 
   return (PyObject *) self;
--