Skip to content

Commit c4556f0

Browse files
committed
fix dangling string in dmx_input createConfig()
problem: DmxVersionString was destroyed when createConfig() returns, so software_version_label became dangling already before dmx_driver_install(inputPortNum, &config, ...) consumes the configuration on Line 151 workaround: give the string static lifetime, so it stays valid after the function returns (MT-safe because the version does not change while WLED runs)
1 parent 347f533 commit c4556f0

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

wled00/dmx_input.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static dmx_config_t createConfig()
5353
config.product_category = RDM_PRODUCT_CATEGORY_FIXTURE;
5454
config.software_version_id = VERSION;
5555

56-
#if 0
56+
#if ESP_IDF_VERSION_MAJOR < 5
5757
// softhack007: ToDO: current code from main does not work in V5 yet
5858
const std::string dmxWledVersionString = "WLED_V" + std::to_string(VERSION);
5959
strncpy(config.software_version_label, dmxWledVersionString.c_str(), 32);
@@ -84,8 +84,8 @@ static dmx_config_t createConfig()
8484
// rdm personalities are numbered from 1, thus we can just set the DMXMode directly.
8585
config.current_personality = DMXMode;
8686
#else
87-
// fallback code
88-
const std::string DmxVersionString = "WLED_V" + std::to_string(VERSION);
87+
// fallback code for V5, without config.personalities[]
88+
static const std::string DmxVersionString = "WLED_V" + std::to_string(VERSION); // static needed, to prevent that config.software_version_label becomes a dangling reference
8989
config.software_version_label = DmxVersionString.c_str();
9090
#endif
9191

0 commit comments

Comments
 (0)