Fixed chat_createnpcchat() not checking if a chatroom already exists, producing memleaks in certain situations (bugreport:2325).

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@13269 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
ultramage 2008-10-08 13:15:35 +00:00
parent 5789db9356
commit 90ad9f3a8c
3 changed files with 13 additions and 2 deletions

View File

@ -4,6 +4,7 @@
#include "../common/cbasetypes.h" #include "../common/cbasetypes.h"
#include "../common/malloc.h" #include "../common/malloc.h"
#include "../common/nullpo.h" #include "../common/nullpo.h"
#include "../common/showmsg.h"
#include "../common/strlib.h" #include "../common/strlib.h"
#include "atcommand.h" // msg_txt() #include "atcommand.h" // msg_txt()
#include "battle.h" // struct battle_config #include "battle.h" // struct battle_config
@ -293,6 +294,12 @@ int chat_createnpcchat(struct npc_data* nd, const char* title, int limit, bool p
struct chat_data* cd; struct chat_data* cd;
nullpo_retr(0, nd); nullpo_retr(0, nd);
if( nd->chat_id )
{
ShowError("chat_createnpcchat: npc '%s' already has a chatroom, cannot create new one!\n", nd->exname);
return 0;
}
cd = chat_createchat(&nd->bl, title, "", limit, pub, trigger, ev); cd = chat_createchat(&nd->bl, title, "", limit, pub, trigger, ev);
if( cd ) if( cd )
{ {

View File

@ -1328,9 +1328,10 @@ void clif_changemapserver(struct map_session_data* sd, unsigned short map_index,
void clif_blown(struct block_list *bl) void clif_blown(struct block_list *bl)
{ {
//Aegis packets says fixpos, but it's unsure whether slide works better or not. //Aegis packets says fixpos, but it's unsure whether slide works better or not.
// return clif_fixpos(bl); // clif_fixpos(bl);
clif_slide(bl, bl->x, bl->y); clif_slide(bl, bl->x, bl->y);
} }
/*========================================== /*==========================================
* *
*------------------------------------------*/ *------------------------------------------*/

View File

@ -8461,8 +8461,11 @@ BUILDIN_FUNC(waitingroom)
ev = script_getstr(st, 4); ev = script_getstr(st, 4);
trigger = limit; trigger = limit;
} }
if( (nd=(struct npc_data *)map_id2bl(st->oid)) != NULL )
nd = (struct npc_data *)map_id2bl(st->oid);
if( nd != NULL )
chat_createnpcchat(nd, title, limit, pub, trigger, ev); chat_createnpcchat(nd, title, limit, pub, trigger, ev);
return 0; return 0;
} }