Bug fix, allocate string to store ledmap name

This commit is contained in:
Ewoud
2023-05-29 18:33:49 +02:00
parent 8c5e589020
commit b1e9f825ca
2 changed files with 8 additions and 4 deletions

View File

@@ -1379,7 +1379,8 @@ void WS2812FX::enumerateLedmaps() {
f = WLED_FS.open(fileName, "r"); f = WLED_FS.open(fileName, "r");
if (f) { if (f) {
f.find("\"n\":"); f.find("\"n\":");
const char *name = f.readStringUntil('\n').c_str(); char name[33];
f.readBytesUntil('\n', name, sizeof(name));
USER_PRINTF("enumerateLedmaps %s %s\n", fileName, name); USER_PRINTF("enumerateLedmaps %s %s\n", fileName, name);
size_t len = 0; size_t len = 0;
@@ -2145,10 +2146,13 @@ bool WS2812FX::deserializeMap(uint8_t n) {
//WLEDMM: read width and height (mandatory in file!!) //WLEDMM: read width and height (mandatory in file!!)
f.find("\"width\":"); f.find("\"width\":");
uint16_t maxWidth = f.readStringUntil('\n').toInt(); f.readBytesUntil('\n', fileName, sizeof(fileName)); //hack: use fileName as we have this allocated already
uint16_t maxWidth = atoi(fileName);
f.find("\"height\":"); f.find("\"height\":");
uint16_t maxHeight = f.readStringUntil('\n').toInt(); f.readBytesUntil('\n', fileName, sizeof(fileName));
uint16_t maxHeight = atoi(fileName);
USER_PRINTF("deserializeMap %d x %d\n", maxWidth, maxHeight); USER_PRINTF("deserializeMap %d x %d\n", maxWidth, maxHeight);
if (maxWidth * maxHeight <= 0) { if (maxWidth * maxHeight <= 0) {

View File

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