aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kunzelmann <max@mxzero.net>2023-11-09 17:37:14 +0100
committerLukas Fleischer <lfleischer@calcurse.org>2024-01-26 13:38:33 +0100
commit343ba5bfdf18a755b289f433a8768bbd437c6e69 (patch)
tree0316cc936c7219422c6bd83f961c1898bdd68754
parent81953ef75a36bc959bd5b6161ff0dc2cf3406676 (diff)
downloadcalcurse-343ba5bfdf18a755b289f433a8768bbd437c6e69.tar.gz
calcurse-343ba5bfdf18a755b289f433a8768bbd437c6e69.zip
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>
-rw-r--r--src/recur.c14
1 files 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);
}