mirror of
https://github.com/mborgerding/kissfft.git
synced 2026-10-31 20:18:57 -04:00
Fix infinite loop in kiss_fft_next_fast_size for n<=0 (issue #121)
kiss_fft_next_fast_size(0) never terminated because the factorization loop divides m by 2/3/5 forever when m stays 0. Per maintainer decision, return 1 for n<=0. Add regression test next_fast_size covering n=0, n<0 and positive inputs.
This commit is contained in:
@@ -411,6 +411,8 @@ void kiss_fft_cleanup(void)
|
||||
|
||||
int kiss_fft_next_fast_size(int n)
|
||||
{
|
||||
if (n <= 0) /* nothing to factor; avoid infinite loop for n<=0 */
|
||||
return 1;
|
||||
while(1) {
|
||||
int m=n;
|
||||
while ( (m%2) == 0 ) m/=2;
|
||||
|
||||
Reference in New Issue
Block a user