usermod udp_name_sync : properly initialize packet if segment name is empty

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
pull/4859/head
Liliputech 2025-08-24 13:52:39 +02:00 zatwierdzone przez GitHub
rodzic 2082b01a3c
commit f3e3f585df
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
1 zmienionych plików z 8 dodań i 7 usunięć

Wyświetl plik

@ -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 : "";