Skip to content

Commit 2e266ec

Browse files
committed
use fixes-size stack buffer
... protected against array overflow due to previous "if (packetSize <= UDPSOUND_MAX_PACKET)"
1 parent 3a8e19d commit 2e266ec

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

usermods/audioreactive/audio_reactive.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@ class AudioReactive : public Usermod {
10951095
#endif
10961096
if ((packetSize > 5) && (packetSize <= UDPSOUND_MAX_PACKET)) {
10971097
//DEBUGSR_PRINTLN("Received UDP Sync Packet");
1098-
static uint8_t fftBuff[UDPSOUND_MAX_PACKET+1] = { 0 }; // static buffer for receiving, to reuse the same memory and avoid heap fragmentation
1098+
uint8_t fftBuff[UDPSOUND_MAX_PACKET+1] = { 0 }; // fixed-size buffer for receiving (stack), to avoid heap fragmentation caused by variable sized arrays
10991099
fftUdp.read(fftBuff, packetSize);
11001100

11011101
// VERIFY THAT THIS IS A COMPATIBLE PACKET

0 commit comments

Comments
 (0)