From 0a3ec8c596a7b256b4a6236e22ed222201102876 Mon Sep 17 00:00:00 2001 From: Yukari Hafner Date: Sun, 12 Jan 2025 10:40:06 +0100 Subject: [PATCH] Error if framesize is not power of two. --- src/segments/fft.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/segments/fft.c b/src/segments/fft.c index 3250840..3fc4e00 100644 --- a/src/segments/fft.c +++ b/src/segments/fft.c @@ -279,12 +279,13 @@ int fft_segment_set(uint32_t field, void *value, struct mixed_segment *segment){ data->samplerate = *(uint32_t *)value; break; case MIXED_FRAMESIZE: - if(*(uint32_t *)value <= 0 || 1<<13 < *(uint32_t *)value){ + { uint32_t framesize = *(uint32_t *)value; + if(framesize <= 2 || 1<<13 < framesize || (framesize & (framesize - 1)) == 0){ mixed_err(MIXED_INVALID_VALUE); return 0; } - data->framesize = *(uint32_t *)value; - break; + data->framesize = framesize; + }break; case MIXED_OVERSAMPLING: if(*(uint32_t *)value <= 0){ mixed_err(MIXED_INVALID_VALUE);