Fix mDNS memory leak

pull/8103/head
caffreyfans 2021-12-17 16:05:38 +08:00
rodzic 07bfc09d0c
commit f5ffd53aeb
1 zmienionych plików z 3 dodań i 0 usunięć

Wyświetl plik

@ -2296,6 +2296,7 @@ static mdns_service_t * _mdns_create_service(const char * service, const char *
if (hostname) { if (hostname) {
s->hostname = strndup(hostname, MDNS_NAME_BUF_LEN - 1); s->hostname = strndup(hostname, MDNS_NAME_BUF_LEN - 1);
if (!s->hostname) { if (!s->hostname) {
free((char *)s->instance);
free(s); free(s);
return NULL; return NULL;
} }
@ -2305,12 +2306,14 @@ static mdns_service_t * _mdns_create_service(const char * service, const char *
s->service = strndup(service, MDNS_NAME_BUF_LEN - 1); s->service = strndup(service, MDNS_NAME_BUF_LEN - 1);
if (!s->service) { if (!s->service) {
free((char *)s->instance);
free(s); free(s);
return NULL; return NULL;
} }
s->proto = strndup(proto, MDNS_NAME_BUF_LEN - 1); s->proto = strndup(proto, MDNS_NAME_BUF_LEN - 1);
if (!s->proto) { if (!s->proto) {
free((char *)s->instance);
free((char *)s->service); free((char *)s->service);
free(s); free(s);
return NULL; return NULL;