shithub: aubio

Download patch

ref: 4b167218b7b9cd4dab59b4bd9d378fd3c7592188
parent: 519d5d30fc1b3722802cc7c8821823eb6bbce25a
author: Paul Brossier <piem@piem.org>
date: Fri Dec 21 12:16:18 EST 2018

[source_sndfile] set error message when reading after close

--- a/src/io/source_sndfile.c
+++ b/src/io/source_sndfile.c
@@ -174,6 +174,12 @@
       s->hop_size, read_data->length);
   sf_count_t read_samples = aubio_sf_read_smpl (s->handle, s->scratch_data,
       s->scratch_size);
+  if (!s->handle) {
+    AUBIO_ERR("source_sndfile: could not read from %s (file was closed)\n",
+        s->path);
+    *read = 0;
+    return;
+  }
 
   uint_t read_length = read_samples / s->input_channels;
 
@@ -219,6 +225,12 @@
       s->path, s->input_channels, read_data->height);
   sf_count_t read_samples = aubio_sf_read_smpl (s->handle, s->scratch_data,
       s->scratch_size);
+  if (!s->handle) {
+    AUBIO_ERR("source_sndfile: could not read from %s (file was closed)\n",
+        s->path);
+    *read = 0;
+    return;
+  }
 
   uint_t read_length = read_samples / s->input_channels;