From 88b43f9cb3bb318b08fe577bec57319a16398106 Mon Sep 17 00:00:00 2001 From: Clemens Kirchgatterer Date: Thu, 11 Jul 2019 10:06:17 +0200 Subject: [PATCH] Fix buffer overflow bug in peak array The peak array is only 7 bytes long, but there are 8 bytes written to it. This overwrites the variable, that the compiler decides to put afterwards, most likely the sample buffer vReal[]. Maybe this is also the reason why you decided to omit the first sample when iterating through vReal[]? --- .../Arduino/microphone_esp8266_fft/microphone_esp8266_fft.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/microphone_esp8266_fft/Arduino/microphone_esp8266_fft/microphone_esp8266_fft.ino b/microphone_esp8266_fft/Arduino/microphone_esp8266_fft/microphone_esp8266_fft.ino index bd4c16e..1322fc6 100644 --- a/microphone_esp8266_fft/Arduino/microphone_esp8266_fft/microphone_esp8266_fft.ino +++ b/microphone_esp8266_fft/Arduino/microphone_esp8266_fft/microphone_esp8266_fft.ino @@ -19,7 +19,7 @@ arduinoFFT FFT = arduinoFFT(); int amplitude = 200; unsigned int sampling_period_us; unsigned long microseconds; -byte peak[] = {0, 0, 0, 0, 0, 0, 0}; +byte peak[] = {0, 0, 0, 0, 0, 0, 0, 0}; double vReal[SAMPLES]; double vImag[SAMPLES]; unsigned long newTime, oldTime; @@ -114,4 +114,4 @@ void loop() Serial.println(); ws2812fx.service(); -} \ No newline at end of file +}