From: Paul Brossier Date: Fri, 21 Dec 2018 16:16:18 +0000 (+0100) Subject: [source_sndfile] set error message when reading after close X-Git-Tag: 0.4.9~27 X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=4b167218b7b9cd4dab59b4bd9d378fd3c7592188;p=aubio.git [source_sndfile] set error message when reading after close --- 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;