From 05debeeda0c727bb299950e1abb8b27465943e07 Mon Sep 17 00:00:00 2001 From: ultramage Date: Thu, 24 Dec 2009 12:19:34 +0000 Subject: Fixed a memleak that occurs when a player exits while waiting on a script select() or menu() (caused by r12481). The change made the attached script not deallocate to avoid a crash when changing mapservers, however deallocation must occur here since scripts waiting for user input are unable to free themselves. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14213 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/unit.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/map/unit.c') diff --git a/src/map/unit.c b/src/map/unit.c index f739159fb..fd89559f2 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -2015,12 +2015,11 @@ int unit_free(struct block_list *bl, int clrtype) sd->regstr = NULL; sd->regstr_num = 0; } - //Tell the script to end, not delete it, it will free itself when necessary [Kevin] - // TODO review this assumption, possible source of memory leaks [FlavioJS] - if( sd->st ) - { - sd->st->rid = 0; - sd->st->state = END; + if( sd->st && sd->st->state != RUN ) + {// free attached scripts that are waiting + script_free_state(sd->st); + sd->st = NULL; + sd->npc_id = 0; } break; } -- cgit v1.2.3-60-g2f50