From ef12aaa60b274b18205e2e8bd2c057c58f431f82 Mon Sep 17 00:00:00 2001 From: Ewoud Date: Wed, 17 May 2023 15:07:42 +0200 Subject: [PATCH] Temp fix for leds array crashes: size fixed to 10000pixels/30000bytes --- wled00/FX.h | 2 +- wled00/FX_fcn.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/wled00/FX.h b/wled00/FX.h index c3685677..0a11f278 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -513,7 +513,7 @@ typedef struct Segment { Segment& operator= (Segment &&orig) noexcept; // move assignment #ifdef WLED_DEBUG - size_t getSize() const { return sizeof(Segment) + (data?_dataLen:0) + (name?strlen(name):0) + (_t?sizeof(Transition):0) + (!Segment::_globalLeds && leds?sizeof(CRGB)*length():0); } + size_t getSize() const { return sizeof(Segment) + (data?_dataLen:0) + (name?strlen(name):0) + (_t?sizeof(Transition):0) + (!Segment::_globalLeds && leds?sizeof(CRGB)*10000:0); } #endif inline bool getOption(uint8_t n) const { return ((options >> n) & 0x01); } diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 275f91f2..daf75419 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -93,7 +93,7 @@ Segment::Segment(const Segment &orig) { if (orig.name) { name = new char[strlen(orig.name)+1]; if (name) strcpy(name, orig.name); } if (orig.data) { if (allocateData(orig._dataLen)) memcpy(data, orig.data, orig._dataLen); } if (orig._t) { _t = new Transition(orig._t->_dur, orig._t->_briT, orig._t->_cctT, orig._t->_colorT); } - if (orig.leds && !Segment::_globalLeds) { leds = (CRGB*)malloc(sizeof(CRGB)*length()); if (leds) memcpy(leds, orig.leds, sizeof(CRGB)*length()); } + if (orig.leds && !Segment::_globalLeds) { leds = (CRGB*)malloc(sizeof(CRGB)*10000); if (leds) memcpy(leds, orig.leds, sizeof(CRGB)*10000); } jMap = nullptr; //WLEDMM jMap } @@ -130,7 +130,7 @@ Segment& Segment::operator= (const Segment &orig) { if (orig.name) { name = new char[strlen(orig.name)+1]; if (name) strcpy(name, orig.name); } if (orig.data) { if (allocateData(orig._dataLen)) memcpy(data, orig.data, orig._dataLen); } if (orig._t) { _t = new Transition(orig._t->_dur, orig._t->_briT, orig._t->_cctT, orig._t->_colorT); } - if (orig.leds && !Segment::_globalLeds) { leds = (CRGB*)malloc(sizeof(CRGB)*length()); if (leds) memcpy(leds, orig.leds, sizeof(CRGB)*length()); } + if (orig.leds && !Segment::_globalLeds) { leds = (CRGB*)malloc(sizeof(CRGB)*10000); if (leds) memcpy(leds, orig.leds, sizeof(CRGB)*10000); } jMap = nullptr; //WLEDMM jMap } return *this; @@ -209,10 +209,10 @@ void Segment::setUpLeds() { else if (!leds) { #if defined(ARDUINO_ARCH_ESP32) && defined(BOARD_HAS_PSRAM) && defined(WLED_USE_PSRAM) if (psramFound()) - leds = (CRGB*)ps_malloc(sizeof(CRGB)*length()); // WLEDMM: stupid - PSRAM is too slow for this !!! + leds = (CRGB*)ps_malloc(sizeof(CRGB)*10000); // WLEDMM: stupid - PSRAM is too slow for this !!! else #endif - leds = (CRGB*)malloc(sizeof(CRGB)*length()); + leds = (CRGB*)malloc(sizeof(CRGB)*10000); } }