From 4a6749a22c4b92cab5a0154a916a2ad606560316 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Tue, 18 Oct 2022 18:28:52 +0300 Subject: [PATCH 47/47] load_rulesetdir(): Destroy actionfile See osdn #45909 Signed-off-by: Marko Lindqvist --- server/ruleset.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/server/ruleset.c b/server/ruleset.c index e19b3ce84d..a5d7f60eca 100644 --- a/server/ruleset.c +++ b/server/ruleset.c @@ -9216,7 +9216,7 @@ static bool load_rulesetdir(const char *rsdir, bool compat_mode, { struct section_file *techfile, *unitfile, *buildfile, *govfile, *terrfile; struct section_file *stylefile, *cityfile, *nationfile, *effectfile, *gamefile; - struct section_file *actionfile; + struct section_file *actionfile = NULL; bool ok = TRUE; struct rscompat_info compat_info; @@ -9287,7 +9287,7 @@ static bool load_rulesetdir(const char *rsdir, bool compat_mode, if (ok) { /* Can only happen here because 3.1 rulesets may not have a - * actions.ruleset. remember to in 3.3 move it with the others. */ + * actions.ruleset. Remember to move it with the others in 3.3. */ if (compat_info.version < RSFORMAT_3_2) { if (!compat_info.compat_mode) { ok = FALSE; @@ -9296,8 +9296,7 @@ static bool load_rulesetdir(const char *rsdir, bool compat_mode, } else { load_ruleset_actions(gamefile, &compat_info); } - } - else { + } else { actionfile = openload_ruleset_file("actions", rsdir); if (actionfile == NULL) { ok = FALSE; @@ -9383,6 +9382,11 @@ static bool load_rulesetdir(const char *rsdir, bool compat_mode, nullcheck_secfile_destroy(effectfile); nullcheck_secfile_destroy(gamefile); + /* Format < RSFORMAT_3_2 allows actionfile to be NULL */ + if (actionfile != NULL) { + nullcheck_secfile_destroy(actionfile); + } + if (extra_sections) { free(extra_sections); extra_sections = NULL; -- 2.35.1