summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2015-03-14 04:02:57 +0100
committerHaru <haru@dotalux.com>2015-03-14 04:06:36 +0100
commit1e8223a21236bce8f13074d943f8c2055eaaa726 (patch)
treeda4abcab9e2ebfbb94e79d11645ca630a2c8564e /src/map
parent2b71c036298756d294d10141ce6196a48d783930 (diff)
downloadhercules-1e8223a21236bce8f13074d943f8c2055eaaa726.tar.gz
hercules-1e8223a21236bce8f13074d943f8c2055eaaa726.tar.bz2
hercules-1e8223a21236bce8f13074d943f8c2055eaaa726.tar.xz
hercules-1e8223a21236bce8f13074d943f8c2055eaaa726.zip
Fixed a script function related memory leak on mapserver shutdown
- If a script function was running when the server is shut down, the memory allocated by its local variables would not get freed. - Special thanks to Ind. Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map')
-rw-r--r--src/map/script.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/map/script.c b/src/map/script.c
index 235b7b8d5..39f8a7b63 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -3387,15 +3387,13 @@ void script_free_code(struct script_code* code)
{
nullpo_retv(code);
- if( code->instances )
+ if (code->instances)
script->stop_instances(code);
- else {
- script->free_vars(code->local.vars);
- if( code->local.arrays )
- code->local.arrays->destroy(code->local.arrays,script->array_free_db);
- }
- aFree( code->script_buf );
- aFree( code );
+ script->free_vars(code->local.vars);
+ if (code->local.arrays)
+ code->local.arrays->destroy(code->local.arrays,script->array_free_db);
+ aFree(code->script_buf);
+ aFree(code);
}
/// Creates a new script state.