[io] avoid crash when calling vorbis_close twice
authorPaul Brossier <piem@piem.org>
Fri, 14 Dec 2018 13:59:14 +0000 (14:59 +0100)
committerPaul Brossier <piem@piem.org>
Fri, 14 Dec 2018 13:59:14 +0000 (14:59 +0100)
src/io/sink_vorbis.c

index 3205ad0..0b95557 100644 (file)
@@ -271,11 +271,12 @@ uint_t aubio_sink_vorbis_close (aubio_sink_vorbis_t *s)
 
   aubio_sink_vorbis_write(s);
 
-  if (fclose(s->fid)) {
+  if (s->fid && fclose(s->fid)) {
     AUBIO_ERR("sink_vorbis: Error closing file %s (%s)\n",
         s->path, strerror(errno));
     return AUBIO_FAIL;
   }
+  s->fid = NULL;
   return AUBIO_OK;
 }