ref: fc633f3e1c4c6cfe64fd93279b3f2720e7909536
parent: 6dc211bb25365943bf783abf7d9745f19e826223
author: Paul Brossier <piem@piem.org>
date: Fri Dec 21 11:40:24 EST 2018
[source_avcodec] prevent reading after close
--- a/src/io/source_avcodec.c
+++ b/src/io/source_avcodec.c
@@ -491,6 +491,12 @@
uint_t total_wrote = 0;
uint_t length = aubio_source_validate_input_length("source_avcodec", s->path,
s->hop_size, read_data->length);
+ if (!s->avr || !s->avFormatCtx || !s->avCodecCtx) {
+ AUBIO_ERR("source_avcodec: could not read from %s (file was closed)\n",
+ s->path);
+ *read= 0;
+ return;
+ }
while (total_wrote < length) {
end = MIN(s->read_samples - s->read_index, length - total_wrote);
for (i = 0; i < end; i++) {
@@ -529,6 +535,12 @@
s->hop_size, read_data->length);
uint_t channels = aubio_source_validate_input_channels("source_avcodec",
s->path, s->input_channels, read_data->height);
+ if (!s->avr || !s->avFormatCtx || !s->avCodecCtx) {
+ AUBIO_ERR("source_avcodec: could not read from %s (file was closed)\n",
+ s->path);
+ *read= 0;
+ return;
+ }
while (total_wrote < length) {
end = MIN(s->read_samples - s->read_index, length - total_wrote);
for (j = 0; j < channels; j++) {