diary

Text-based journaling program
git clone https://git.in0rdr.ch/diary.git
Log | Files | Refs | README | LICENSE

commit cd8a337feaa95ebba2dbdd7948fcab9ed9da950a
parent 449224331846fd958f594a84159f843f5fc8678f
Author: Andreas Gruhler <agruhl@gmx.ch>
Date:   Wed, 24 Nov 2021 20:53:57 +0100

fix mem leak when canceling import

Diffstat:
Msrc/import.c | 13+++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/import.c b/src/import.c @@ -38,6 +38,9 @@ void ics_import(const char* ics_input, WINDOW* header, WINDOW* cal, WINDOW* asid vevent_date = extract_ical_field(i, "DTSTART", &search_pos, false); vevent_desc = extract_ical_field(i, "DESCRIPTION", &search_pos, true); if (vevent == NULL || vevent_desc == NULL) { + free(vevent); + free(vevent_date); + free(vevent_desc); break; } @@ -56,7 +59,9 @@ void ics_import(const char* ics_input, WINDOW* header, WINDOW* cal, WINDOW* asid fprintf(stderr, "Import date file path: %s\n", path); if (conf_ch == 'c') { - // cancel all + free(vevent); + free(vevent_date); + free(vevent_desc); break; } @@ -111,9 +116,9 @@ void ics_import(const char* ics_input, WINDOW* header, WINDOW* cal, WINDOW* asid // fprintf(stderr, "Import DTSTART: %s\n", desc); // fprintf(stderr, "Import DESCRIPTION: %s\n", desc); fprintf(stderr, "* * * * * * * * * * * * * \n"); + free(vevent); + free(vevent_date); + free(vevent_desc); } - free(vevent); - free(vevent_date); - free(vevent_desc); free(ics); } \ No newline at end of file