From 0a387f98deccf50ae9e6b2abd933ee34e862ea09 Mon Sep 17 00:00:00 2001 From: Suren Gabrielyan Date: Thu, 20 May 2021 12:25:15 +0400 Subject: [PATCH] mdns: Fix of crash when wifi interface get deleted and mdns receives the packets Closes https://github.com/espressif/esp-idf/issues/6973 --- components/mdns/mdns.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/components/mdns/mdns.c b/components/mdns/mdns.c index 1436072abe..71a1db14a1 100644 --- a/components/mdns/mdns.c +++ b/components/mdns/mdns.c @@ -73,6 +73,17 @@ esp_netif_t *_mdns_get_esp_netif(mdns_if_t tcpip_if) return NULL; } + +/* + * @brief Clean internal mdns interface's pointer + */ +static inline void _mdns_clean_netif_ptr(mdns_if_t tcpip_if) { + if (tcpip_if < MDNS_IF_MAX) { + s_esp_netifs[tcpip_if] = NULL; + } +} + + /* * @brief Convert esp-netif handle to mdns if */ @@ -3110,6 +3121,8 @@ void _mdns_enable_pcb(mdns_if_t tcpip_if, mdns_ip_protocol_t ip_protocol) */ void _mdns_disable_pcb(mdns_if_t tcpip_if, mdns_ip_protocol_t ip_protocol) { + _mdns_clean_netif_ptr(tcpip_if); + if (_mdns_server->interfaces[tcpip_if].pcbs[ip_protocol].pcb) { _mdns_clear_pcb_tx_queue_head(tcpip_if, ip_protocol); _mdns_pcb_deinit(tcpip_if, ip_protocol);