From: Arran Cudbard-Bell Date: Fri, 28 Mar 2025 05:45:29 +0000 (-0600) Subject: Passing a NULL pointer to fr_timer_disarm is a noop X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=18372ce9b711fcda784d54da8c6cc947a52c82fd;p=thirdparty%2Ffreeradius-server.git Passing a NULL pointer to fr_timer_disarm is a noop --- diff --git a/src/lib/util/timer.c b/src/lib/util/timer.c index 66f6983c5b5..419cdfbdc3b 100644 --- a/src/lib/util/timer.c +++ b/src/lib/util/timer.c @@ -605,13 +605,15 @@ static int timer_ordered_disarm(fr_timer_t *ev) */ int fr_timer_disarm(fr_timer_t *ev) { - fr_timer_list_t *tl = ev->tl; + fr_timer_list_t *tl; - if (!EVENT_ARMED(ev)) { + if (!ev || !EVENT_ARMED(ev)) { EVENT_DEBUG("Asked to disarm inactive timer %p (noop)", ev); return 0; /* Noop */ } + tl = ev->tl; + EVENT_DEBUG("Disarming timer %p", ev); CHECK_PARENT(ev); diff --git a/src/lib/util/timer.h b/src/lib/util/timer.h index 9fd7a63c663..778c24dbc4b 100644 --- a/src/lib/util/timer.h +++ b/src/lib/util/timer.h @@ -85,7 +85,7 @@ int _fr_timer_in(NDEBUG_LOCATION_ARGS CC_HINT(nonnull(NDEBUG_LOCATION_NONNULL(2), NDEBUG_LOCATION_NONNULL(3), NDEBUG_LOCATION_NONNULL(6))); #define fr_timer_in(...) _fr_timer_in(NDEBUG_LOCATION_EXP __VA_ARGS__) -int fr_timer_disarm(fr_timer_t *ev) CC_HINT(nonnull); /* disarms but does not free */ +int fr_timer_disarm(fr_timer_t *ev); /* disarms but does not free */ int fr_timer_delete(fr_timer_t **ev_p) CC_HINT(nonnull); /* disarms AND frees */