From f13f8927b17391c9efd4a603aa08e8f87cefad15 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Mon, 11 May 2020 21:38:01 +0200 Subject: [PATCH] esp-timer: fix (ignore) false positive memory alloc/free issue found by static analyser --- components/esp_timer/src/esp_timer.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/esp_timer/src/esp_timer.c b/components/esp_timer/src/esp_timer.c index 0a7d95d764..2bbb439e5e 100644 --- a/components/esp_timer/src/esp_timer.c +++ b/components/esp_timer/src/esp_timer.c @@ -281,7 +281,11 @@ static void timer_process_alarm(esp_timer_dispatch_t dispatch_method) int64_t now = esp_timer_impl_get_time(); esp_timer_handle_t it = LIST_FIRST(&s_timers); while (it != NULL && - it->alarm < now) { + it->alarm < now) { // NOLINT(clang-analyzer-unix.Malloc) + // Static analyser reports "Use of memory after it is freed" since the "it" variable + // is freed below (if EVENT_ID_DELETE_TIMER) and assigned to the (new) LIST_FIRST() + // so possibly (if the "it" hasn't been removed from the list) it might keep the same ptr. + // Ignoring this warning, as this couldn't happen if queue.h used to populate the list LIST_REMOVE(it, list_entry); if (it->event_id == EVENT_ID_DELETE_TIMER) { free(it);