protect start byte
If Channel is less than 0, it's clamped to 0 on line 134. Then on line 138, dmxData[0] is written with the value, overwriting the start byte that was just set on line 137. DMX Channel numbers should be 1-based (1-512). The bounds check should clamp Channel to a minimum of 1, not 0, to prevent corrupting the start byte Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -131,7 +131,7 @@ uint8_t SparkFunDMX::read(int Channel) {
|
||||
|
||||
// Function to send DMX data
|
||||
void SparkFunDMX::write(int Channel, uint8_t value) {
|
||||
if (Channel < 0) Channel = 0;
|
||||
if (Channel < 1) Channel = 1;
|
||||
if (Channel+1 > chanSize) chanSize = min(dmxMaxChannel +1, Channel+1); // WLEDMM "+1" as we need to account for start byte
|
||||
if (Channel > dmxMaxChannel) Channel = dmxMaxChannel; // WLEDMM prevent array out-of-bounds access
|
||||
dmxData[0] = 0;
|
||||
|
||||
Reference in New Issue
Block a user