From 33f4e8cf736d23eacedd00e0cf9ab8a0f5c7c49b Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Fri, 2 Dec 2022 20:08:11 +0100 Subject: [PATCH] pinmanager bugfix for -S2/-S3 pinmanager ran out out array bounds on -S2 and -S3, as these MCUs have more than 40 GPIO. As consequence, memory was overwriten, and pins > 39 were reported as "allocated" but not "owned". Thisfixes the problem, by extending internal arrays so that up to 50 pins can be managed. --- wled00/pin_manager.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wled00/pin_manager.h b/wled00/pin_manager.h index 6b613e61..a2c0e36b 100644 --- a/wled00/pin_manager.h +++ b/wled00/pin_manager.h @@ -69,9 +69,9 @@ class PinManagerClass { uint8_t pinAlloc[3] = {0x00, 0x00, 0x00}; //24bit, 1 bit per pin, we use first 17bits PinOwner ownerTag[17] = { PinOwner::None }; #else - uint8_t pinAlloc[5] = {0x00, 0x00, 0x00, 0x00, 0x00}; //40bit, 1 bit per pin, we use all bits + uint8_t pinAlloc[7] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; // 56bit, 1 bit per pin, we use 50 bits on ESP32-S3 uint8_t ledcAlloc[2] = {0x00, 0x00}; //16 LEDC channels - PinOwner ownerTag[40] = { PinOwner::None }; + PinOwner ownerTag[50] = { PinOwner::None }; // new MCU's have up to 50 GPIO #endif struct { uint8_t i2cAllocCount : 4; // allow multiple allocation of I2C bus pins but keep track of allocations