usermod udp_name_sync : properly initialize packet if segment name is empty

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
Liliputech 2025-08-24 13:52:39 +02:00 committed by GitHub
parent 2082b01a3c
commit f3e3f585df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -36,13 +36,14 @@ class UdpNameSync : public Usermod {
byte udpOut[WLED_MAX_SEGNAME_LEN + 2]; byte udpOut[WLED_MAX_SEGNAME_LEN + 2];
udpOut[0] = 2; // 0: wled notifier protocol, 1: warls protocol, 2 is free udpOut[0] = 2; // 0: wled notifier protocol, 1: warls protocol, 2 is free
if (strlen(segmentName) && !mainseg.name) { //name is back to null if (strlen(segmentName) && !mainseg.name) { // name cleared
notifierUdp.beginPacket(broadcastIp, udpPort); notifierUdp.beginPacket(broadcastIp, udpPort);
strcpy(segmentName,""); segmentName[0] = '\0';
DEBUG_PRINTLN(F("UdpNameSync: sending Null name")); DEBUG_PRINTLN(F("UdpNameSync: sending empty name"));
notifierUdp.write( udpOut , 2); udpOut[1] = 0; // explicit empty string
notifierUdp.endPacket(); notifierUdp.write(udpOut, 2);
return; notifierUdp.endPacket();
return;
} }
const char* curName = mainseg.name ? mainseg.name : ""; const char* curName = mainseg.name ? mainseg.name : "";