summaryrefslogtreecommitdiff
path: root/newgrf_config.c
diff options
context:
space:
mode:
authorDarkvater <Darkvater@openttd.org>2006-12-21 10:09:43 +0000
committerDarkvater <Darkvater@openttd.org>2006-12-21 10:09:43 +0000
commit5cd081b6cd357ab1774091a680183eb5ba69ebc3 (patch)
treefc0687324cb1df9abba5c770d3c759f84383915d /newgrf_config.c
parent85cd063a9dccddcca3aa1bf635e07a1730dd90f1 (diff)
downloadopenttd-5cd081b6cd357ab1774091a680183eb5ba69ebc3.tar.xz
(svn r7522) -Codechange: Have CopyGRFConfigList clear the destination list before assigning
values to it. This cuts down on memleaks which could exist when the function was not used carefully.
Diffstat (limited to 'newgrf_config.c')
-rw-r--r--newgrf_config.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/newgrf_config.c b/newgrf_config.c
index f1b9b00ea..b70c8354f 100644
--- a/newgrf_config.c
+++ b/newgrf_config.c
@@ -115,6 +115,8 @@ GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src)
{
GRFConfig *c;
+ /* Clear destination as it will be overwritten */
+ ClearGRFConfigList(dst);
for (; src != NULL; src = src->next) {
c = calloc(1, sizeof(*c));
*c = *src;
@@ -135,8 +137,6 @@ void ResetGRFConfig(bool defaults)
{
GRFConfig **c = &_grfconfig;
- ClearGRFConfigList(c);
-
if (defaults) c = CopyGRFConfigList(c, _grfconfig_newgame);
CopyGRFConfigList(c, _grfconfig_static);
}