Skip to content

Commit

Permalink
Fix memory leak by freeing linked lists in recurrence rules
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Max Kunzelmann authored and Lukas Fleischer committed Jan 26, 2024
1 parent 81953ef commit 343ba5b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/recur.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down

0 comments on commit 343ba5b

Please sign in to comment.