Fix crash when connect commands change network

Fixes #2084
This commit is contained in:
Patrick Griffis 2017-10-25 15:26:26 -04:00
parent a3db4e5773
commit c6d9e26e2b

View File

@ -1558,6 +1558,7 @@ inbound_login_end (session *sess, char *text, const message_tags_data *tags_data
GSList *cmdlist; GSList *cmdlist;
commandentry *cmd; commandentry *cmd;
server *serv = sess->server; server *serv = sess->server;
ircnet *net = serv->network;
if (!serv->end_of_motd) if (!serv->end_of_motd)
{ {
@ -1568,29 +1569,32 @@ inbound_login_end (session *sess, char *text, const message_tags_data *tags_data
} }
set_default_modes (serv); set_default_modes (serv);
if (serv->network) if (net)
{ {
/* there may be more than 1, separated by \n */ /* there may be more than 1, separated by \n */
cmdlist = ((ircnet *)serv->network)->commandlist; cmdlist = net->commandlist;
while (cmdlist) while (cmdlist)
{ {
cmd = cmdlist->data; cmd = cmdlist->data;
inbound_exec_eom_cmd (cmd->command, sess); inbound_exec_eom_cmd (cmd->command, sess);
cmdlist = cmdlist->next; cmdlist = cmdlist->next;
} }
}
/* The previously ran commands can alter the state of the server */
if (serv->network != net)
return;
/* send nickserv password */ /* send nickserv password */
if (((ircnet *)serv->network)->pass && inbound_nickserv_login (serv)) if (net && net->pass && inbound_nickserv_login (serv))
{ {
serv->p_ns_identify (serv, ((ircnet *)serv->network)->pass); serv->p_ns_identify (serv, net->pass);
}
} }
/* wait for join if command or nickserv set */ /* wait for join if command or nickserv set */
if (serv->network && prefs.hex_irc_join_delay if (net && prefs.hex_irc_join_delay
&& ((((ircnet *)serv->network)->pass && inbound_nickserv_login (serv)) && ((net->pass && inbound_nickserv_login (serv))
|| ((ircnet *)serv->network)->commandlist)) || net->commandlist))
{ {
serv->joindelay_tag = fe_timeout_add_seconds (prefs.hex_irc_join_delay, check_autojoin_channels, serv); serv->joindelay_tag = fe_timeout_add_seconds (prefs.hex_irc_join_delay, check_autojoin_channels, serv);
} }