From efd979b8fa978854e25b0dc79d4d8aab8064aa07 Mon Sep 17 00:00:00 2001 From: xufulong Date: Sun, 26 Sep 2021 20:43:10 +0800 Subject: [PATCH] check nb_samples --- app/src/main/cpp/visualizer/execute_fft.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/cpp/visualizer/execute_fft.cpp b/app/src/main/cpp/visualizer/execute_fft.cpp index f8338d0..e38febe 100644 --- a/app/src/main/cpp/visualizer/execute_fft.cpp +++ b/app/src/main/cpp/visualizer/execute_fft.cpp @@ -228,7 +228,10 @@ void release_visualizer(filter_sys_t *p_filter) } int ensure_memory(filter_sys_t *fft_filter, int nb_samples) { - if (nb_samples != fft_filter->nb_samples && nb_samples >= MIN_FFT_SIZE) { + if (nb_samples < MIN_FFT_SIZE) { + return -1; + } + if (nb_samples != fft_filter->nb_samples) { if (!fft_filter->data) { fft_filter->data_size = nb_samples; fft_filter->data = (uint8_t *) (malloc(nb_samples * sizeof(uint8_t)));