summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2009-12-24 12:19:34 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2009-12-24 12:19:34 +0000
commit05debeeda0c727bb299950e1abb8b27465943e07 (patch)
tree26b18af76694928c6732b841b5a84c59754638d2
parent5f9da85571ad494cf3549ce38b170efda21dc7c7 (diff)
downloadhercules-05debeeda0c727bb299950e1abb8b27465943e07.tar.gz
hercules-05debeeda0c727bb299950e1abb8b27465943e07.tar.bz2
hercules-05debeeda0c727bb299950e1abb8b27465943e07.tar.xz
hercules-05debeeda0c727bb299950e1abb8b27465943e07.zip
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
-rw-r--r--src/map/unit.c11
1 files changed, 5 insertions, 6 deletions
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;
}