From 8675002e687d09387fc787b77ccb98ca5abf287e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 29 Oct 2015 09:56:53 +0100 Subject: [PATCH] coverity scan CIDs 22540 22541 22546: resource leak the calendar should only ever be initialized once, but based on static analysis, I agree that this was sloppy. --- src/kernel/xmlreader.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 12406dff6..fdaad4b51 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -389,7 +389,8 @@ static int parse_calendar(xmlDocPtr doc) int i; weeks_per_month = nsetWeeks->nodeNr; - assert(!weeknames); + free(weeknames); + free(weeknames2); weeknames = malloc(sizeof(char *) * weeks_per_month); weeknames2 = malloc(sizeof(char *) * weeks_per_month); for (i = 0; i != nsetWeeks->nodeNr; ++i) { @@ -431,9 +432,11 @@ static int parse_calendar(xmlDocPtr doc) int i; months_per_year = nsetMonths->nodeNr; - assert(!monthnames); + free(monthnames); monthnames = malloc(sizeof(char *) * months_per_year); + free(month_season); month_season = malloc(sizeof(int) * months_per_year); + free(storms); storms = malloc(sizeof(int) * months_per_year); for (i = 0; i != nsetMonths->nodeNr; ++i) {