python/ext/py-source.c: copy string uri
authorPaul Brossier <piem@piem.org>
Mon, 27 Feb 2017 09:26:01 +0000 (10:26 +0100)
committerPaul Brossier <piem@piem.org>
Mon, 27 Feb 2017 09:26:01 +0000 (10:26 +0100)
python/ext/py-sink.c
python/ext/py-source.c

index 15956d0..53db845 100644 (file)
@@ -80,9 +80,10 @@ Py_sink_new (PyTypeObject * pytype, PyObject * args, PyObject * kwds)
     return NULL;
   }
 
-  self->uri = "none";
+  self->uri = NULL;
   if (uri != NULL) {
-    self->uri = uri;
+    self->uri = (char_t *)malloc(sizeof(char_t) * (strnlen(uri, PATH_MAX) + 1));
+    strncpy(self->uri, uri, strnlen(uri, PATH_MAX) + 1);
   }
 
   self->samplerate = Py_aubio_default_samplerate;
index d7dbe70..bc78292 100644 (file)
@@ -100,9 +100,10 @@ Py_source_new (PyTypeObject * pytype, PyObject * args, PyObject * kwds)
     return NULL;
   }
 
-  self->uri = "none";
+  self->uri = NULL;
   if (uri != NULL) {
-    self->uri = uri;
+    self->uri = (char_t *)malloc(sizeof(char_t) * (strnlen(uri, PATH_MAX) + 1));
+    strncpy(self->uri, uri, strnlen(uri, PATH_MAX) + 1);
   }
 
   self->samplerate = 0;