From 0baee932111268c4a2103e1c1adeb7d99914a937 Mon Sep 17 00:00:00 2001 From: Jiacheng Guo Date: Wed, 23 Jun 2021 20:17:23 +0800 Subject: [PATCH 1/2] mdns: fix memory leak in mdns_free when adding delegated hostnames --- components/mdns/mdns.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/components/mdns/mdns.c b/components/mdns/mdns.c index 4ff5ae8f73..8fb6bd2757 100644 --- a/components/mdns/mdns.c +++ b/components/mdns/mdns.c @@ -4181,6 +4181,13 @@ static void _mdns_free_action(mdns_action_t * action) pbuf_free(action->data.rx_handle.packet->pb); free(action->data.rx_handle.packet); break; + case ACTION_DELEGATE_HOSTNAME_ADD: + free((char *)action->data.delegate_hostname.hostname); + free_address_list(action->data.delegate_hostname.address_list); + break; + case ACTION_DELEGATE_HOSTNAME_REMOVE: + free((char *)action->data.delegate_hostname.hostname); + break; default: break; } From 2386113972ee51ea93e9740d8c34bfe9289ce909 Mon Sep 17 00:00:00 2001 From: Jiacheng Guo Date: Tue, 29 Jun 2021 15:18:44 +0800 Subject: [PATCH 2/2] mdns: return ESP_OK rather than ERR_OK in API functions --- components/mdns/mdns.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/mdns/mdns.c b/components/mdns/mdns.c index 8fb6bd2757..e55f8c1945 100644 --- a/components/mdns/mdns.c +++ b/components/mdns/mdns.c @@ -4801,7 +4801,7 @@ esp_err_t mdns_hostname_set(const char * hostname) return ESP_ERR_NO_MEM; } xTaskNotifyWait(0, 0, NULL, portMAX_DELAY); - return ERR_OK; + return ESP_OK; } esp_err_t mdns_delegate_hostname_add(const char * hostname, const mdns_ip_addr_t * address_list) @@ -4831,7 +4831,7 @@ esp_err_t mdns_delegate_hostname_add(const char * hostname, const mdns_ip_addr_t free(action); return ESP_ERR_NO_MEM; } - return ERR_OK; + return ESP_OK; } esp_err_t mdns_delegate_hostname_remove(const char * hostname) @@ -4860,7 +4860,7 @@ esp_err_t mdns_delegate_hostname_remove(const char * hostname) free(action); return ESP_ERR_NO_MEM; } - return ERR_OK; + return ESP_OK; } bool mdns_hostname_exists(const char * hostname) @@ -4894,7 +4894,7 @@ esp_err_t mdns_instance_name_set(const char * instance) free(action); return ESP_ERR_NO_MEM; } - return ERR_OK; + return ESP_OK; } /*