From 68d887636ed29c4d95d02215ba98130649a0fb83 Mon Sep 17 00:00:00 2001 From: Pierre <105686771+pieturin@users.noreply.github.com> Date: Mon, 12 Aug 2024 13:38:20 -0700 Subject: [PATCH] Fix crash in active defrag (#883) This crash would happen if we disable active defrag while it is running, then re-enable active defrag. In this case the `expires_cursor` variable in `activeDefragCycle()` would not be reset to 0 when disabling active defrag, so when re-enabling it, this variable can still be non-zero, which causes the `db` and other variables to not be initialized before starting the defrag process. Signed-off-by: Pierre Turin --- src/defrag.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/defrag.c b/src/defrag.c index ff63cf8fd..25b4ee45a 100644 --- a/src/defrag.c +++ b/src/defrag.c @@ -941,6 +941,7 @@ void activeDefragCycle(void) { defrag_later_cursor = 0; current_db = -1; cursor = 0; + expires_cursor = 0; db = NULL; goto update_metrics; }