From f3e3f585dfc25e731f08dd71f957aad830e72f12 Mon Sep 17 00:00:00 2001 From: Liliputech Date: Sun, 24 Aug 2025 13:52:39 +0200 Subject: [PATCH] usermod udp_name_sync : properly initialize packet if segment name is empty Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- usermods/udp_name_sync/udp_name_sync.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/usermods/udp_name_sync/udp_name_sync.cpp b/usermods/udp_name_sync/udp_name_sync.cpp index cd279386..31a271fe 100644 --- a/usermods/udp_name_sync/udp_name_sync.cpp +++ b/usermods/udp_name_sync/udp_name_sync.cpp @@ -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 : "";