From 6090b06f6cf97d637229914d740df246a199b754 Mon Sep 17 00:00:00 2001 From: scilor Date: Fri, 21 May 2021 19:44:57 +0200 Subject: [PATCH] Fix Protocol 2 (Fragment) --- HyperionRGB/WrapperUdpLed.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/HyperionRGB/WrapperUdpLed.cpp b/HyperionRGB/WrapperUdpLed.cpp index 921abe1..94ac6a1 100644 --- a/HyperionRGB/WrapperUdpLed.cpp +++ b/HyperionRGB/WrapperUdpLed.cpp @@ -68,26 +68,26 @@ void WrapperUdpLed::handleProtocolFragment(int bytes) { /// 1: Fragment ?! /// 2: First LED ID, high byte / 3: First LED ID, low byte --> int16_t? /// 4: {0: R, 1: G, 2: B} - if (bytes > 4) { + if (bytes > 4 && bytes-4 <= _bufferSize) { _udp.readBytes(_udpBuffer, 4); byte updateId = _udpBuffer[0] & 0x0F; byte fragment = _udpBuffer[1]; int ledIdStart = 256 * _udpBuffer[2] + _udpBuffer[3]; //Multiply high byte int ledIdEnd = ledIdStart + (bytes - 4) / 3; - + Log.verbose("updateId: %X, fragment: %X, ledIdStart: %i, ledIdEnd: %i", updateId, fragment, ledIdStart, ledIdEnd); if (ledIdEnd <= _ledCount) { _udp.readBytes(_udpBuffer, bytes - 4); - for (int i = ledIdStart; i < ledIdEnd; i++) { - updateLed(i, _udpBuffer[i * 3 + 0], _udpBuffer[i * 3 + 1], _udpBuffer[i * 3 + 2]); + for (int i=0; i