]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
sched: reset timer queue in finalization
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 19 Jun 2023 14:10:45 +0000 (16:10 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Mon, 19 Jun 2023 14:15:07 +0000 (16:15 +0200)
Don't leave dangling pointers to timer queue entries when they are
freed in the scheduler finalization in case some code tried to remove
a timer later.

Fixes: 6ea1082a72d8 ("sched: free timer blocks on exit")
sched.c

diff --git a/sched.c b/sched.c
index 1505dc3a2e1b45d19a9570ea6c7e858f177f8c13..676866efe9bc0f8417ce02c8a542dc47917ed52f 100644 (file)
--- a/sched.c
+++ b/sched.c
@@ -163,6 +163,8 @@ SCH_Finalise(void) {
 
   ARR_DestroyInstance(file_handlers);
 
+  timer_queue.next = &timer_queue;
+  timer_queue.prev = &timer_queue;
   for (i = 0; i < ARR_GetSize(tqe_blocks); i++)
     Free(*(TimerQueueEntry **)ARR_GetElement(tqe_blocks, i));
   ARR_DestroyInstance(tqe_blocks);