mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Fix mDNS memory leak
This commit is contained in:
parent
f5ffd53aeb
commit
119b4a9dd1
@ -2296,9 +2296,7 @@ static mdns_service_t * _mdns_create_service(const char * service, const char *
|
||||
if (hostname) {
|
||||
s->hostname = strndup(hostname, MDNS_NAME_BUF_LEN - 1);
|
||||
if (!s->hostname) {
|
||||
free((char *)s->instance);
|
||||
free(s);
|
||||
return NULL;
|
||||
goto fail;
|
||||
}
|
||||
} else {
|
||||
s->hostname = NULL;
|
||||
@ -2306,20 +2304,27 @@ static mdns_service_t * _mdns_create_service(const char * service, const char *
|
||||
|
||||
s->service = strndup(service, MDNS_NAME_BUF_LEN - 1);
|
||||
if (!s->service) {
|
||||
free((char *)s->instance);
|
||||
free(s);
|
||||
return NULL;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
s->proto = strndup(proto, MDNS_NAME_BUF_LEN - 1);
|
||||
if (!s->proto) {
|
||||
free((char *)s->instance);
|
||||
free((char *)s->service);
|
||||
free(s);
|
||||
return NULL;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
return s;
|
||||
|
||||
fail:
|
||||
if (s->instance) {
|
||||
free(s->instance);
|
||||
}
|
||||
if (s->hostname) {
|
||||
free(s->hostname);
|
||||
}
|
||||
free(s);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user