From 9a4da97fb4b3c241998cb969a08c3a917ffb4cd1 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Thu, 14 Feb 2019 16:39:11 +0100 Subject: [PATCH] mdns: fix memory leak when query for service receives multiple ptr entries for one instance fixes redmine issue 27300 --- components/mdns/mdns.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/mdns/mdns.c b/components/mdns/mdns.c index 1626ffaeb8..1bce6db43f 100644 --- a/components/mdns/mdns.c +++ b/components/mdns/mdns.c @@ -2741,8 +2741,10 @@ void mdns_parse_packet(mdns_rx_packet_t * packet) if (search_result) { if (search_result->type == MDNS_TYPE_PTR) { - result->port = port; - result->hostname = strdup(name->host); + if (!result->hostname) { // assign host/port for this entry only if not previously set + result->port = port; + result->hostname = strdup(name->host); + } } else { _mdns_search_result_add_srv(search_result, name->host, port, packet->tcpip_if, packet->ip_protocol); }