From 58b566cda6ca3550825a0eaf28dd80af5bc0116f Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Thu, 10 Jun 2021 13:32:00 -0400 Subject: [PATCH] TT#14008 call the free func only if set This avoids possible segfault by calling 0x0 Change-Id: Ib45c19d8cf785887cc20f8a07cf30bea270c85e1 --- daemon/timerthread.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/daemon/timerthread.c b/daemon/timerthread.c index 31a61b7cc..ee06bfa1d 100644 --- a/daemon/timerthread.c +++ b/daemon/timerthread.c @@ -142,7 +142,8 @@ void timerthread_queue_run(void *ptr) { static int ttqe_free_all(void *k, void *v, void *d) { struct timerthread_queue *ttq = d; - ttq->entry_free_func(k); + if (ttq->entry_free_func) + ttq->entry_free_func(k); return FALSE; } @@ -266,7 +267,8 @@ unsigned int timerthread_queue_flush(struct timerthread_queue *ttq, void *ptr) { while (matches.length) { struct timerthread_queue_entry *ttqe = g_queue_pop_head(&matches); g_tree_remove(ttq->entries, ttqe); - ttq->entry_free_func(ttqe); + if (ttq->entry_free_func) + ttq->entry_free_func(ttqe); num++; }