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 <max@mxzero.net>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
Max Kunzelmann 2023-11-09 17:37:14 +01:00 committed by Lukas Fleischer
parent 81953ef75a
commit 343ba5bfdf

View File

@ -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);
}