[io] prevent possible crash on empty string in source_apple_audio
[aubio.git] / src / io / source_apple_audio.c
index db7ff54..d8b33af 100644 (file)
@@ -59,7 +59,7 @@ aubio_source_apple_audio_t * new_aubio_source_apple_audio(const char_t * path, u
 {
   aubio_source_apple_audio_t * s = AUBIO_NEW(aubio_source_apple_audio_t);
 
-  if (path == NULL) {
+  if (path == NULL || strnlen(path, PATH_MAX) < 1) {
     AUBIO_ERROR("source_apple_audio: Aborted opening null path\n");
     goto beach;
   }
@@ -85,7 +85,7 @@ aubio_source_apple_audio_t * new_aubio_source_apple_audio(const char_t * path, u
   return s;
 
 beach:
-  AUBIO_FREE(s);
+  del_aubio_source_apple_audio(s);
   return NULL;
 }