fix some calendar-related leaks and issues

This commit is contained in:
Enno Rehling 2016-09-09 18:39:38 +02:00
parent 43aacd2355
commit cb381123ff
4 changed files with 27 additions and 11 deletions

View File

@ -38,22 +38,34 @@ void calendar_cleanup(void)
free(agename); free(agename);
if (seasonnames) {
for (i = 0; i != seasons; ++i) { for (i = 0; i != seasons; ++i) {
free(seasonnames[i]); free(seasonnames[i]);
} }
free(seasonnames); free(seasonnames);
seasonnames = 0;
}
if (monthnames) {
for (i = 0; i != months_per_year; ++i) { for (i = 0; i != months_per_year; ++i) {
free(monthnames[i]); free(monthnames[i]);
} }
free(storms); free(storms);
storms = 0;
free(month_season); free(month_season);
month_season = 0;
free(monthnames); free(monthnames);
monthnames = 0;
}
for (i = 0; i != weeks_per_month; ++i) { for (i = 0; i != weeks_per_month; ++i) {
if (weeknames)
free(weeknames[i]); free(weeknames[i]);
if (weeknames2)
free(weeknames2[i]); free(weeknames2[i]);
} }
free(weeknames); free(weeknames);
weeknames = 0;
free(weeknames2); free(weeknames2);
weeknames2 = 0;
} }

View File

@ -26,6 +26,7 @@
#include <util/message.h> #include <util/message.h>
#include <races/races.h> #include <races/races.h>
#include "calendar.h"
#include "chaos.h" #include "chaos.h"
#include "creport.h" #include "creport.h"
#include "items.h" #include "items.h"
@ -50,8 +51,8 @@ void game_done(void)
#ifdef REPORT_FORMAT_NR #ifdef REPORT_FORMAT_NR
report_cleanup(); report_cleanup();
#endif #endif
calendar_cleanup();
#endif #endif
calendar_cleanup();
free_functions(); free_functions();
free_config(); free_config();
free_locales(); free_locales();

View File

@ -471,6 +471,8 @@ static int parse_calendar(xmlDocPtr doc)
} }
xmlXPathFreeObject(xpathMonths); xmlXPathFreeObject(xpathMonths);
xmlXPathFreeObject(xpathSeasons); xmlXPathFreeObject(xpathSeasons);
xmlFree(newyear);
newyear = NULL;
} }
xmlXPathFreeObject(xpathCalendars); xmlXPathFreeObject(xpathCalendars);
xmlXPathFreeContext(xpath); xmlXPathFreeContext(xpath);

View File

@ -3,3 +3,4 @@ turn = get_turn()
eressea.free_game() eressea.free_game()
print("trying to read data from " .. turn) print("trying to read data from " .. turn)
eressea.read_game(turn .. ".dat") eressea.read_game(turn .. ".dat")
eressea.free_game()