From 343ba5bfdf18a755b289f433a8768bbd437c6e69 Mon Sep 17 00:00:00 2001 From: Max Kunzelmann Date: Thu, 9 Nov 2023 17:37:14 +0100 Subject: Fix memory leak by freeing linked lists in recurrence rules The function responsible for freeing a recurring appointment or event did not free the linked lists contained in the `struct rpt` holding the recurrence rules. This led to memory leaks if a user had recurring appointments or events. Found with ASAN. Signed-off-by: Max Kunzelmann Signed-off-by: Lukas Fleischer --- src/recur.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/recur.c b/src/recur.c index 12f76b8..10523ad 100644 --- a/src/recur.c +++ b/src/recur.c @@ -253,8 +253,13 @@ void recur_apoint_free(struct recur_apoint *rapt) mem_free(rapt->mesg); if (rapt->note) mem_free(rapt->note); - if (rapt->rpt) + if (rapt->rpt) { + recur_free_exc_list(&rapt->rpt->exc); + recur_free_int_list(&rapt->rpt->bywday); + recur_free_int_list(&rapt->rpt->bymonth); + recur_free_int_list(&rapt->rpt->bymonthday); mem_free(rapt->rpt); + } recur_free_exc_list(&rapt->exc); mem_free(rapt); } @@ -264,8 +269,13 @@ void recur_event_free(struct recur_event *rev) mem_free(rev->mesg); if (rev->note) mem_free(rev->note); - if (rev->rpt) + if (rev->rpt) { + recur_free_exc_list(&rev->rpt->exc); + recur_free_int_list(&rev->rpt->bywday); + recur_free_int_list(&rev->rpt->bymonth); + recur_free_int_list(&rev->rpt->bymonthday); mem_free(rev->rpt); + } recur_free_exc_list(&rev->exc); mem_free(rev); } -- cgit v1.2.3-70-g09d2