esp_event: fix possibility of null ptr dereference

Closes https://github.com/espressif/esp-idf/issues/4373
pull/4494/head
Renz Christian Bagaporo 2019-11-25 14:27:10 +08:00
rodzic dbae85dde8
commit bb139d2b83
1 zmienionych plików z 3 dodań i 3 usunięć

Wyświetl plik

@ -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) {