From bb139d2b83478f7fad8a6036bb6f90702fab1a76 Mon Sep 17 00:00:00 2001 From: Renz Christian Bagaporo Date: Mon, 25 Nov 2019 14:27:10 +0800 Subject: [PATCH] esp_event: fix possibility of null ptr dereference Closes https://github.com/espressif/esp-idf/issues/4373 --- components/esp_event/esp_event.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/esp_event/esp_event.c b/components/esp_event/esp_event.c index be55d952f5..a346d2f348 100644 --- a/components/esp_event/esp_event.c +++ b/components/esp_event/esp_event.c @@ -678,15 +678,15 @@ esp_err_t esp_event_handler_register_with(esp_event_loop_handle_t event_loop, es (last_loop_node && !SLIST_EMPTY(&(last_loop_node->base_nodes)) && is_loop_level_handler)) { loop_node = (esp_event_loop_node_t*) calloc(1, sizeof(*loop_node)); - SLIST_INIT(&(loop_node->handlers)); - SLIST_INIT(&(loop_node->base_nodes)); - if (!loop_node) { ESP_LOGE(TAG, "alloc for new loop node failed"); err = ESP_ERR_NO_MEM; goto on_err; } + SLIST_INIT(&(loop_node->handlers)); + SLIST_INIT(&(loop_node->base_nodes)); + err = loop_node_add_handler(loop_node, event_base, event_id, event_handler, event_handler_arg); if (err == ESP_OK) {