From: Paul Brossier Date: Wed, 19 Dec 2018 13:49:22 +0000 (+0100) Subject: [tests] avoid test-sink crash on missing input file X-Git-Tag: 0.4.9~81 X-Git-Url: https://git.aubio.org/?p=aubio.git;a=commitdiff_plain;h=387b605e7539ce6e8a637bed7dd869271960dfaa [tests] avoid test-sink crash on missing input file --- diff --git a/tests/src/io/base-sink_custom.h b/tests/src/io/base-sink_custom.h index 0c5219d1..150ecc92 100644 --- a/tests/src/io/base-sink_custom.h +++ b/tests/src/io/base-sink_custom.h @@ -25,17 +25,21 @@ int base_main(int argc, char **argv) char_t *source_path = argv[1]; char_t *sink_path = argv[2]; + aubio_source_t *i = NULL; + aubio_sink_custom_t *o = NULL; + if ( argc >= 4 ) samplerate = atoi(argv[3]); if ( argc >= 5 ) hop_size = atoi(argv[4]); fvec_t *vec = new_fvec(hop_size); + if (!vec) { err = 1; goto failure; } - aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size); + i = new_aubio_source(source_path, samplerate, hop_size); + if (!i) { err = 1; goto failure; } if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i); - aubio_sink_custom_t *o = new_aubio_sink_custom(sink_path, samplerate); - - if (!vec || !i || !o) { err = 1; goto failure; } + o = new_aubio_sink_custom(sink_path, samplerate); + if (!o) { err = 1; goto failure; } do { aubio_source_do(i, vec, &read); diff --git a/tests/src/io/test-sink.c b/tests/src/io/test-sink.c index 79a9602c..08247fb1 100644 --- a/tests/src/io/test-sink.c +++ b/tests/src/io/test-sink.c @@ -21,17 +21,21 @@ int main(int argc, char **argv) char_t *source_path = argv[1]; char_t *sink_path = argv[2]; + aubio_source_t *i = NULL; + aubio_sink_t *o = NULL; + if ( argc >= 4 ) samplerate = atoi(argv[3]); if ( argc >= 5 ) hop_size = atoi(argv[4]); fvec_t *vec = new_fvec(hop_size); + if (!vec) { err = 1; goto failure; } - aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size); + i = new_aubio_source(source_path, samplerate, hop_size); + if (!i) { err = 1; goto failure; } if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i); - aubio_sink_t *o = new_aubio_sink(sink_path, samplerate); - - if (!vec || !i || !o) { err = 1; goto failure; } + o = new_aubio_sink(sink_path, samplerate); + if (!o) { err = 1; goto failure; } do { aubio_source_do(i, vec, &read);