diff --git a/modules/core/m_join.c b/modules/core/m_join.c index 2eb9d7b7..8d61ef94 100644 --- a/modules/core/m_join.c +++ b/modules/core/m_join.c @@ -74,7 +74,7 @@ static void do_join_0(struct Client *client_p, struct Client *source_p); static bool check_channel_name_loc(struct Client *source_p, const char *name); static void send_join_error(struct Client *source_p, int numeric, const char *name); -static void set_final_mode(struct Mode *mode, struct Mode *oldmode); +static char *set_final_mode(char *mbuf, struct Mode *mode, struct Mode *oldmode); static void remove_our_modes(struct Channel *chptr, struct Client *source_p); static void remove_ban_list(struct Channel *chptr, struct Client *source_p, @@ -83,7 +83,6 @@ static void remove_ban_list(struct Channel *chptr, struct Client *source_p, static char modebuf[MODEBUFLEN]; static char parabuf[MODEBUFLEN]; static const char *para[MAXMODEPARAMS]; -static char *mbuf; static int pargs; /* Check what we will forward to, without sending any notices to the user @@ -406,6 +405,7 @@ ms_join(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_ bool isnew; bool keep_our_modes = true; rb_dlink_node *ptr, *next_ptr; + char *mbuf; /* special case for join 0 */ if((parv[1][0] == '0') && (parv[1][1] == '\0') && parc == 2) @@ -460,7 +460,7 @@ ms_join(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_ /* Lost the TS, other side wins, so remove modes on this side */ if(!keep_our_modes) { - set_final_mode(&mode, &chptr->mode); + mbuf = set_final_mode(mbuf, &mode, &chptr->mode); chptr->mode = mode; remove_our_modes(chptr, source_p); RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->invites.head) @@ -531,6 +531,7 @@ ms_sjoin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source int i, joinc = 0, timeslice = 0; static char empty[] = ""; rb_dlink_node *ptr, *next_ptr; + char *mbuf; if(parc < 5) return; @@ -704,7 +705,7 @@ ms_sjoin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source chptr->join_count = chptr->join_delta = 0; } - set_final_mode(&mode, oldmode); + mbuf = set_final_mode(mbuf, &mode, oldmode); chptr->mode = mode; /* Lost the TS, other side wins, so remove modes on this side */ @@ -1037,8 +1038,8 @@ send_join_error(struct Client *source_p, int numeric, const char *name) } } -static void -set_final_mode(struct Mode *mode, struct Mode *oldmode) +static char * +set_final_mode(char *mbuf, struct Mode *mode, struct Mode *oldmode) { int dir = MODE_QUERY; char *pbuf = parabuf; @@ -1157,6 +1158,8 @@ set_final_mode(struct Mode *mode, struct Mode *oldmode) pbuf += len; } *mbuf = '\0'; + + return mbuf; } /* @@ -1175,8 +1178,8 @@ remove_our_modes(struct Channel *chptr, struct Client *source_p) char *lpara[MAXMODEPARAMS]; int count = 0; int i; + char *mbuf = lmodebuf; - mbuf = lmodebuf; *mbuf++ = '-'; for(i = 0; i < MAXMODEPARAMS; i++) @@ -1275,6 +1278,7 @@ remove_ban_list(struct Channel *chptr, struct Client *source_p, char *pbuf; int count = 0; int cur_len, mlen, plen; + char *mbuf; pbuf = lparabuf;