From 4b167218b7b9cd4dab59b4bd9d378fd3c7592188 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Fri, 21 Dec 2018 17:16:18 +0100 Subject: [PATCH] [source_sndfile] set error message when reading after close --- src/io/source_sndfile.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/io/source_sndfile.c b/src/io/source_sndfile.c index 51bd0a9b..d2b98a5c 100644 --- a/src/io/source_sndfile.c +++ b/src/io/source_sndfile.c @@ -174,6 +174,12 @@ void aubio_source_sndfile_do(aubio_source_sndfile_t * s, fvec_t * read_data, uin 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 @@ void aubio_source_sndfile_do_multi(aubio_source_sndfile_t * s, fmat_t * read_dat 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; -- 2.11.0