]> granicus.if.org Git - esp-idf/commitdiff
mdns: Fix case where service is NULL and that will cause exception
authorme-no-dev <hristo@espressif.com>
Mon, 22 Jan 2018 12:17:59 +0000 (13:17 +0100)
committerIvan Grokhotkov <ivan@espressif.com>
Mon, 22 Jan 2018 15:27:24 +0000 (23:27 +0800)
components/mdns/mdns.c

index bc8a94e3fa742b74d97c4c32d79e4263d6e009a4..13368c3ed9f073fd5346b06d5a2727c9b80400f7 100644 (file)
@@ -1304,6 +1304,10 @@ static mdns_tx_packet_t * _mdns_get_next_pcb_packet(tcpip_adapter_if_t tcpip_if,
  */
 static void _mdns_remove_scheduled_answer(tcpip_adapter_if_t tcpip_if, mdns_ip_protocol_t ip_protocol, uint16_t type, mdns_srv_item_t * service)
 {
+    mdns_srv_item_t s = {NULL, NULL};
+    if (!service) {
+        service = &s;
+    }
     mdns_tx_packet_t * q = _mdns_server->tx_queue_head;
     while (q) {
         if (q->tcpip_if == tcpip_if && q->ip_protocol == ip_protocol && q->distributed) {
@@ -1336,6 +1340,10 @@ static void _mdns_dealloc_answer(mdns_out_answer_t ** destnation, uint16_t type,
     if (!d) {
         return;
     }
+    mdns_srv_item_t s = {NULL, NULL};
+    if (!service) {
+        service = &s;
+    }
     if (d->type == type && d->service == service->service) {
         *destnation = d->next;
         free(d);