python/ext/py-source.c: check seek is not negative
authorPaul Brossier <piem@piem.org>
Sat, 14 May 2016 03:25:34 +0000 (05:25 +0200)
committerPaul Brossier <piem@piem.org>
Sat, 14 May 2016 03:25:34 +0000 (05:25 +0200)
python/ext/py-source.c

index b946070..8280868 100644 (file)
@@ -251,11 +251,18 @@ Pyaubio_source_seek (Py_source *self, PyObject *args)
 {
   uint_t err = 0;
 
-  uint_t position;
+  int position;
   if (!PyArg_ParseTuple (args, "I", &position)) {
     return NULL;
   }
 
+  if (position < 0) {
+    PyErr_Format(PyExc_ValueError,
+        "error when seeking in source: can not seek to negative value %d",
+        position);
+    return NULL;
+  }
+
   err = aubio_source_seek(self->o, position);
   if (err != 0) {
     PyErr_SetString (PyExc_ValueError,