[io] prevent possible crash on empty string in source_apple_audio
[aubio.git] / src / io / source_apple_audio.c
index 715a7e3..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;
 }
 
@@ -279,7 +279,7 @@ beach:
 uint_t aubio_source_apple_audio_close (aubio_source_apple_audio_t *s)
 {
   OSStatus err = noErr;
-  if (!s->audioFile) { return AUBIO_FAIL; }
+  if (!s->audioFile) { return AUBIO_OK; }
   err = ExtAudioFileDispose(s->audioFile);
   s->audioFile = NULL;
   if (err) {