From: pk910 Date: Wed, 21 Dec 2011 23:24:24 +0000 (+0100) Subject: fixed crash in modcmd.c (bots could be destroyed inside a function) X-Git-Tag: v5.3~124 X-Git-Url: http://git.pk910.de/?p=NeonServV5.git;a=commitdiff_plain;h=27b2967b63aab5cfb6029a9ec018a59f665707bc fixed crash in modcmd.c (bots could be destroyed inside a function) --- diff --git a/src/modcmd.c b/src/modcmd.c index 058612a..aca47f6 100644 --- a/src/modcmd.c +++ b/src/modcmd.c @@ -531,6 +531,7 @@ static void got_chanmsg(struct UserNode *user, struct ChanNode *chan, char *mess struct ClientSocket *client; FD_ZERO(&fds); FD_ZERO(&fds2); + got_chanmsg_loop1: for(client = getBots(SOCKET_FLAG_READY, NULL); client; client = getBots(SOCKET_FLAG_READY, client)) { if(isUserOnChan(client->user, chan) && (client->flags & SOCKET_FLAG_PREFERRED) && ((client->botid == 0 && !FD_ISSET(client->clientid, &fds)) || (client->botid && !FD_ISSET(client->botid, &fds2)))) { FD_SET(client->clientid, &fds); @@ -538,16 +539,19 @@ static void got_chanmsg(struct UserNode *user, struct ChanNode *chan, char *mess trigger = get_channel_trigger(client->botid, client->clientid, chan); if(trigger && stricmplen(message, trigger, strlen(trigger)) == 0) { handle_command(client, user, chan, message + strlen(trigger)); + goto got_chanmsg_loop1; //Thats really really bad, i know... But we can't count on the "getBots" list anymore after executing a command } } } + got_chanmsg_loop2: for(client = getBots(SOCKET_FLAG_READY, NULL); client; client = getBots(SOCKET_FLAG_READY, client)) { if(isUserOnChan(client->user, chan) && ((client->botid == 0 && !FD_ISSET(client->clientid, &fds)) || (client->botid && !FD_ISSET(client->botid, &fds2)))) { - FD_SET(client->botid, &fds); + FD_SET(client->clientid, &fds); FD_SET(client->botid, &fds2); trigger = get_channel_trigger(client->botid, client->clientid, chan); if(trigger && stricmplen(message, trigger, strlen(trigger)) == 0) { handle_command(client, user, chan, message + strlen(trigger)); + goto got_chanmsg_loop2; //Thats really really bad, i know... But we can't count on the "getBots" list anymore after executing a command } } }