From: David Cermak <cermak@espressif.com> Date: Fri, 25 Jan 2019 15:17:07 +0000 (+0100) Subject: mdns: fix crash after init if no memory for task X-Git-Tag: v3.3-beta2~62^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a47768dc4e4750fd7e1c29b15d6e2dd3c76e6591;p=esp-idf mdns: fix crash after init if no memory for task mdns init first starts timer task, then starts service task. if service task failed to be created, timer task needs to be stopped too. fixed https://ezredmine.espressif.cn:8765/issues/28466 --- diff --git a/components/mdns/mdns.c b/components/mdns/mdns.c index c77c9443fa..1626ffaeb8 100644 --- a/components/mdns/mdns.c +++ b/components/mdns/mdns.c @@ -3993,7 +3993,10 @@ static esp_err_t _mdns_service_task_start() if (!_mdns_service_task_handle) { xTaskCreatePinnedToCore(_mdns_service_task, "mdns", MDNS_SERVICE_STACK_DEPTH, NULL, 1, (TaskHandle_t * const)(&_mdns_service_task_handle), 0); if (!_mdns_service_task_handle) { + _mdns_stop_timer(); MDNS_SERVICE_UNLOCK(); + vSemaphoreDelete(_mdns_service_semaphore); + _mdns_service_semaphore = NULL; return ESP_FAIL; } } @@ -4012,6 +4015,8 @@ static esp_err_t _mdns_service_task_stop() MDNS_SERVICE_LOCK(); _mdns_stop_timer(); MDNS_SERVICE_UNLOCK(); + vSemaphoreDelete(_mdns_service_semaphore); + _mdns_service_semaphore = NULL; if (_mdns_service_task_handle) { mdns_action_t action; mdns_action_t * a = &action;