diff options
author | shinomori <shinomori@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2005-02-14 20:50:40 +0000 |
---|---|---|
committer | shinomori <shinomori@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2005-02-14 20:50:40 +0000 |
commit | 8fa0cea72c24c464e4e43b081316af34dcf30af7 (patch) | |
tree | de29a771617152dcae91189222be42efd19a8ead /src/map/guild.c | |
parent | 61980833a1b7ffe229712f782f14425ab4fef90e (diff) | |
download | hercules-8fa0cea72c24c464e4e43b081316af34dcf30af7.tar.gz hercules-8fa0cea72c24c464e4e43b081316af34dcf30af7.tar.bz2 hercules-8fa0cea72c24c464e4e43b081316af34dcf30af7.tar.xz hercules-8fa0cea72c24c464e4e43b081316af34dcf30af7.zip |
fixed memory leak in guild_gvg_eliminate_timer and timer handling in npc_event_timer [Shinomori]
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1106 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/guild.c')
-rw-r--r-- | src/map/guild.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/map/guild.c b/src/map/guild.c index 64e2b29d2..72bf302f0 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -1500,15 +1500,21 @@ int guild_agit_end(void) int guild_gvg_eliminate_timer(int tid,unsigned int tick,int id,int data) { // Run One NPC_Event[OnAgitEliminate] - size_t len = strlen((const char*)data); - char *evname=(char*)aCallocA(len + 4,sizeof(char)); + char *name = (char*)data; + size_t len = (name) ? strlen(name) : 0; + // the rest is dangerous, but let it crash, + // if this happens, it's ruined anyway + char *evname=(char*)aMalloc( (len + 4) * sizeof(char)); int c=0; - if(!agit_flag) return 0; // Agit already End - memcpy(evname,(const char *)data,len - 5); - strcpy(evname + len - 5,"Eliminate"); - c = npc_event_do(evname); - printf("NPC_Event:[%s] Run (%d) Events.\n",evname,c); + if(agit_flag) // Agit not already End + { + memcpy(evname,name,len - 5); + strcpy(evname + len - 5,"Eliminate"); + c = npc_event_do(evname); + printf("NPC_Event:[%s] Run (%d) Events.\n",evname,c); + } + if(name) aFree(name); return 0; } |