diff options
author | ailin-nemui <ailin-nemui@users.noreply.github.com> | 2018-02-12 10:54:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-12 10:54:42 +0100 |
commit | ccfb2dabcf5eed702ce28245ba8e7de81c1ec6bb (patch) | |
tree | 53cd1c09645be36e148e898d51be3ff89d78a7f0 | |
parent | 946876b1e9db5d764cecb3f884fc3075765dc94d (diff) | |
parent | 5c5ed64180a6b76315ee7b8c6000ee64ad5877a7 (diff) | |
download | irssi-ccfb2dabcf5eed702ce28245ba8e7de81c1ec6bb.zip |
Merge pull request #832 from ailin-nemui/netsplit-crash
try to make sure the server is still good enough to call ischannel when printing netsplit/join
-rw-r--r-- | src/fe-common/irc/fe-netjoin.c | 19 | ||||
-rw-r--r-- | src/fe-common/irc/fe-netsplit.c | 17 |
2 files changed, 25 insertions, 11 deletions
diff --git a/src/fe-common/irc/fe-netjoin.c b/src/fe-common/irc/fe-netjoin.c index a7a2e4fe..9ea633b4 100644 --- a/src/fe-common/irc/fe-netjoin.c +++ b/src/fe-common/irc/fe-netjoin.c @@ -245,17 +245,24 @@ static void print_netjoins(NETJOIN_SERVER_REC *server, const char *filter_channe message before it. */ static void sig_print_starting(TEXT_DEST_REC *dest) { - GSList *tmp, *next; + NETJOIN_SERVER_REC *rec; if (printing_joins) return; - for (tmp = joinservers; tmp != NULL; tmp = next) { - NETJOIN_SERVER_REC *server = tmp->data; + if (!IS_IRC_SERVER(dest->server)) + return; - next = tmp->next; - if (server->netjoins != NULL) - print_netjoins(server, NULL); + rec = netjoin_find_server(IRC_SERVER(dest->server)); + if (rec != NULL && rec->netjoins != NULL) { + /* if netjoins exists, the server rec should be + still valid. otherwise, calling server->ischannel + may not be safe. */ + if (dest->target != NULL && + !server_ischannel((SERVER_REC *) rec->server, dest->target)) + return; + + print_netjoins(rec, NULL); } } diff --git a/src/fe-common/irc/fe-netsplit.c b/src/fe-common/irc/fe-netsplit.c index edd3fc34..258d0d57 100644 --- a/src/fe-common/irc/fe-netsplit.c +++ b/src/fe-common/irc/fe-netsplit.c @@ -247,16 +247,23 @@ static int check_server_splits(IRC_SERVER_REC *server) message before it. */ static void sig_print_starting(TEXT_DEST_REC *dest) { - GSList *tmp; + IRC_SERVER_REC *rec; if (printing_splits) return; - for (tmp = servers; tmp != NULL; tmp = tmp->next) { - IRC_SERVER_REC *rec = tmp->data; + if (!IS_IRC_SERVER(dest->server)) + return; + + rec = IRC_SERVER(dest->server); + if (rec->split_servers != NULL) { + /* if split_servers exists, the server rec should be + still valid. otherwise, calling server->ischannel + may not be safe. */ + if (dest->target != NULL && !server_ischannel((SERVER_REC *) rec, dest->target)) + return; - if (IS_IRC_SERVER(rec) && rec->split_servers != NULL) - print_splits(rec, NULL); + print_splits(rec, NULL); } } |