ref: ca3acec8ffe3460b8cd80008c31703030f020a10
parent: e24ea5f28db4a83cd388b8727f2a8551e1dac0c3
author: Ulrich Klauer <ulrich@chirlu.de>
date: Tue Oct 11 20:29:30 EDT 2011
fir effect: don't crash when no coefficients are given The fir effect would crash if no parameters were given at all (it would try to open a NULL file name), or if a file containing zero coefficients was given. Now does a no-op (SOX_EFF_NULL) in both cases.
--- a/src/fir.c
+++ b/src/fir.c
@@ -53,7 +53,7 @@
int i;
if (!f->num_taps) {
- if (!p->n) {
+ if (!p->n && p->filename) {
FILE * file = lsx_open_input_file(effp, p->filename);
if (!file)
return SOX_EOF;
@@ -63,7 +63,6 @@
p->h = lsx_realloc(p->h, p->n * sizeof(*p->h));
p->h[p->n - 1] = d;
}
- lsx_report("%i coefficients", p->n);
if (!feof(file)) {
lsx_fail("error reading coefficient file");
if (file != stdin) fclose(file);
@@ -71,6 +70,9 @@
}
if (file != stdin) fclose(file);
}
+ lsx_report("%i coefficients", p->n);
+ if (!p->n)
+ return SOX_EFF_NULL;
lsx_set_dft_filter(f, p->h, p->n, p->n >> 1);
}
return lsx_dft_filter_effect_fn()->start(effp);