Explorar o código

Fix undefined behavior

Mark Giraud %!s(int64=6) %!d(string=hai) anos
pai
achega
91f54454d1
Modificáronse 1 ficheiros con 2 adicións e 1 borrados
  1. 2 1
      src/server/ua_services_discovery_multicast.c

+ 2 - 1
src/server/ua_services_discovery_multicast.c

@@ -418,7 +418,8 @@ UA_Discovery_addRecord(UA_Server *server, const UA_String *servername,
     // TXT record: [servername]-[hostname]._opcua-tcp._tcp.local. TXT path=/ caps=NA,DA,...
     UA_STACKARRAY(char, pathChars, path->length + 1);
     if(createTxt) {
-        memcpy(pathChars, path->data, path->length);
+        if(path->length > 0)
+            memcpy(pathChars, path->data, path->length);
         pathChars[path->length] = 0;
         mdns_create_txt(server, fullServiceDomain, pathChars, capabilites,
                         capabilitiesSize, UA_Discovery_multicastConflict);