xiph/rnnoise

size bug in memset() in denoise.c line 152

jemmyc opened this issue · 5 comments

In denoise.c line 152 should
memset(g, 0, FREQ_SIZE);
instead be
memset(g, 0, FREQ_SIZE*sizeof(float)); ?

Indeed it should. Am running now with this change and have a feeling it's improved the results. reading through the code does confirm your finding, well done!

The code's definitely wrong, but in most cases, it didn't look like the error would change anything (due to other initializations). Did you notice otherwise?

Maybe I feel better running the code with the storage correctly initialised :) . Just been using it on a SDR Radio and it's still working well.

The code's definitely wrong, but in most cases, it didn't look like the error would change anything (due to other initializations). Did you notice otherwise?

I initialized the array to a non-zero value to simulate an uninitialized condition (FREQ_SIZE=480). It looks like the tail end of the array remains uninitialized by the end of the function. If the uninitialized memory happens to be zero, you would not detect a difference; if it happens to be some random value, it is detectable.

Just FWIW my users are noticing an improvement.