|
From: Eric W. <nor...@yh...> - 2014-12-22 22:51:24
|
Pander <pa...@us...> wrote:
> Please review the attached patch for outputting the average power spectrum.
I am not knowledgable in the math behind this, but I noticed one
memory management error:
> @@ -134,6 +138,15 @@ static int sox_stat_flow(sox_effect_t * effp, const sox_sample_t *ibuf, sox_samp
> priv_t * stat = (priv_t *) effp->priv;
> int done, x, len = min(*isamp, *osamp);
> short count = 0;
> + float *re_average;
re_average needs to be initialized for the "stat->fft_average != 1" case
float *re_average = NULL;
> + if (stat->fft_average == 1) {
> + samples = (stat->fft_size / 2);
> + ffa = effp->in_signal.rate / samples;
> + re_average = lsx_malloc(sizeof(float) * (int)samples);
> + }
...otherwise, free may be called on an uninitialized value:
> + if (re_average) {
> + free(re_average);
> + }
> *isamp = *osamp = len;
> /* Process all samples */
There's also a bunch of unrelated whitespace eliminations
in the manpage which should probably be a separate commit
(but I'm not a sox maintainer, just another user + occasional patcher).
|