Memory allocation bugfix.

This commit is contained in:
Blaz Kristan 2022-07-29 20:24:29 +02:00
parent 79337a4568
commit 52b863fe36
3 changed files with 4 additions and 4 deletions

View File

@ -76,7 +76,7 @@ uint32_t color_add(uint32_t,uint32_t);
#ifndef MAX_NUM_SEGMENTS
#define MAX_NUM_SEGMENTS 32
#endif
#define MAX_SEGMENT_DATA 20480
#define MAX_SEGMENT_DATA 32768
#endif
/* How much data bytes each segment should max allocate to leave enough space for other segments,

View File

@ -82,7 +82,7 @@ Segment::Segment(const Segment &orig) {
_dataLen = 0;
//_t = nullptr;
if (orig.name) { name = new char[strlen(orig.name)+1]; if (name) strcpy(name, orig.name); }
if (orig.data) { allocateData(orig._dataLen); memcpy(data, orig.data, orig._dataLen); }
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); }
DEBUG_PRINTF(" Original data: %p (%d)\n", orig.data, (int)orig._dataLen);
DEBUG_PRINTF(" Constructed data: %p (%d)\n", data, (int)_dataLen);
@ -112,7 +112,7 @@ Segment& Segment::operator= (const Segment &orig) {
_dataLen = 0;
//_t = nullptr;
if (orig.name) { name = new char[strlen(orig.name)+1]; if (name) strcpy(name, orig.name); }
if (orig.data) { allocateData(orig._dataLen); memcpy(data, orig.data, orig._dataLen); }
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); }
DEBUG_PRINTF(" Original data: %p (%d)\n", orig.data, (int)orig._dataLen);
DEBUG_PRINTF(" Copied data: %p (%d)\n", data, (int)_dataLen);

View File

@ -8,7 +8,7 @@
*/
// version code in format yymmddb (b = daily build)
#define VERSION 2207292
#define VERSION 2207293
//uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG