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

View File

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