Skip to content

Commit 6582b41

Browse files
mdns: fix memory leak when query for service receives multiple ptr entries for one instance
fixes redmine issue 27300 * Original commit: espressif/esp-idf@9a4da97
1 parent 358d26c commit 6582b41

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

components/mdns/mdns.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2741,8 +2741,10 @@ void mdns_parse_packet(mdns_rx_packet_t * packet)
27412741

27422742
if (search_result) {
27432743
if (search_result->type == MDNS_TYPE_PTR) {
2744-
result->port = port;
2745-
result->hostname = strdup(name->host);
2744+
if (!result->hostname) { // assign host/port for this entry only if not previously set
2745+
result->port = port;
2746+
result->hostname = strdup(name->host);
2747+
}
27462748
} else {
27472749
_mdns_search_result_add_srv(search_result, name->host, port, packet->tcpip_if, packet->ip_protocol);
27482750
}

0 commit comments

Comments
 (0)