diff --git a/components/mdns/mdns.c b/components/mdns/mdns.c index e88672f82b..ad3dfb49e5 100644 --- a/components/mdns/mdns.c +++ b/components/mdns/mdns.c @@ -1312,6 +1312,7 @@ static mdns_tx_packet_t * _mdns_create_probe_packet(tcpip_adapter_if_t tcpip_if, q->domain = MDNS_DEFAULT_DOMAIN; if (!q->host || _mdns_question_exists(q, packet->questions)) { free(q); + continue; } else { queueToEnd(mdns_out_question_t, packet->questions, q); } @@ -2801,7 +2802,7 @@ void mdns_parse_packet(mdns_rx_packet_t * packet) col = 1; } else if (!clas) { col = -1; - } else { + } else if (service) { // only detect srv collision if service existed col = _mdns_check_srv_collision(service->service, priority, weight, port, name->host, name->domain); } if (col && (parsed_packet->probe || parsed_packet->authoritative)) { @@ -3831,23 +3832,25 @@ static void _mdns_execute_action(mdns_action_t * action) break; case ACTION_SERVICE_DEL: a = _mdns_server->services; - if (_mdns_server->services == action->data.srv_del.service) { - _mdns_server->services = a->next; - _mdns_send_bye(&a, 1, false); - _mdns_remove_scheduled_service_packets(a->service); - _mdns_free_service(a->service); - free(a); - } else { - while (a->next && a->next != action->data.srv_del.service) { - a = a->next; - } - if (a->next == action->data.srv_del.service) { - mdns_srv_item_t * b = a->next; - a->next = a->next->next; - _mdns_send_bye(&b, 1, false); - _mdns_remove_scheduled_service_packets(b->service); - _mdns_free_service(b->service); - free(b); + if (action->data.srv_del.service) { + if (_mdns_server->services == action->data.srv_del.service) { + _mdns_server->services = a->next; + _mdns_send_bye(&a, 1, false); + _mdns_remove_scheduled_service_packets(a->service); + _mdns_free_service(a->service); + free(a); + } else { + while (a->next && a->next != action->data.srv_del.service) { + a = a->next; + } + if (a->next == action->data.srv_del.service) { + mdns_srv_item_t * b = a->next; + a->next = a->next->next; + _mdns_send_bye(&b, 1, false); + _mdns_remove_scheduled_service_packets(b->service); + _mdns_free_service(b->service); + free(b); + } } }