diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-09-13 15:21:11 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-09-14 20:23:24 +0300 |
commit | 7dd7498f8ce94aa1392c02da527096182bf533a0 (patch) | |
tree | 61dd6dc1d5bda4a77623910be1cf4d6f396511a6 /src/map/channel.c | |
parent | 7b55511e79318e0b47b6a5dd3d6e309f9df2eb5e (diff) | |
download | hercules-7dd7498f8ce94aa1392c02da527096182bf533a0.tar.gz hercules-7dd7498f8ce94aa1392c02da527096182bf533a0.tar.bz2 hercules-7dd7498f8ce94aa1392c02da527096182bf533a0.tar.xz hercules-7dd7498f8ce94aa1392c02da527096182bf533a0.zip |
Add missing checks into channel.c
Diffstat (limited to 'src/map/channel.c')
-rw-r--r-- | src/map/channel.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/map/channel.c b/src/map/channel.c index 6e15d072e..529d3155e 100644 --- a/src/map/channel.c +++ b/src/map/channel.c @@ -255,6 +255,7 @@ void channel_send(struct channel_data *chan, struct map_session_data *sd, const { char message[150]; nullpo_retv(chan); + nullpo_retv(msg); if (sd && chan->msg_delay != 0 && DIFF_TICK(sd->hchsysch_tick + chan->msg_delay*1000, timer->gettick()) > 0 @@ -262,14 +263,14 @@ void channel_send(struct channel_data *chan, struct map_session_data *sd, const clif->messagecolor_self(sd->fd, COLOR_RED, msg_sd(sd,1455)); return; } else if (sd) { - snprintf(message, 150, "[ #%s ] %s : %s",chan->name,sd->status.name, msg); + safesnprintf(message, 150, "[ #%s ] %s : %s", chan->name, sd->status.name, msg); clif->channel_msg(chan,sd,message); if (chan->type == HCS_TYPE_IRC) ircbot->relay(sd->status.name,msg); if (chan->msg_delay != 0) sd->hchsysch_tick = timer->gettick(); } else { - snprintf(message, 150, "[ #%s ] %s",chan->name, msg); + safesnprintf(message, 150, "[ #%s ] %s", chan->name, msg); clif->channel_msg2(chan, message); if (chan->type == HCS_TYPE_IRC) ircbot->relay(NULL, msg); @@ -329,6 +330,7 @@ enum channel_operation_status channel_join(struct channel_data *chan, struct map nullpo_retr(HCS_STATUS_FAIL, chan); nullpo_retr(HCS_STATUS_FAIL, sd); + nullpo_retr(HCS_STATUS_FAIL, password); if (idb_exists(chan->users, sd->status.char_id)) { return HCS_STATUS_ALREADY; @@ -445,6 +447,7 @@ void channel_leave(struct channel_data *chan, struct map_session_data *sd) */ void channel_quit(struct map_session_data *sd) { + nullpo_retv(sd); while (sd->channel_count > 0) { // Loop downward to avoid unnecessary array compactions by channel_leave struct channel_data *chan = sd->channels[sd->channel_count-1]; @@ -461,10 +464,11 @@ void channel_quit(struct map_session_data *sd) /** * Joins the local map channel. * - * @param sd The target character + * @param sd The target character (sd must be non null) */ void channel_map_join(struct map_session_data *sd) { + nullpo_retv(sd); if (sd->state.autotrade || sd->state.standalone) return; if (!map->list[sd->bl.m].channel) { @@ -475,18 +479,20 @@ void channel_map_join(struct map_session_data *sd) map->list[sd->bl.m].channel->m = sd->bl.m; } - channel->join(map->list[sd->bl.m].channel, sd, NULL, false); + channel->join(map->list[sd->bl.m].channel, sd, "", false); } void channel_irc_join(struct map_session_data *sd) { struct channel_data *chan = ircbot->channel; + + nullpo_retv(sd); if (sd->state.autotrade || sd->state.standalone) return; if (channel->config->irc_name[0] == '\0') return; if (chan) - channel->join(chan, sd, NULL, false); + channel->join(chan, sd, "", false); } /** @@ -548,12 +554,13 @@ void channel_guild_leave_alliance(const struct guild *g_source, const struct gui /** * Makes a character quit all guild-related channels. * - * @param sd The character + * @param sd The character (must be non null) */ void channel_quit_guild(struct map_session_data *sd) { unsigned char i; + nullpo_retv(sd); for (i = 0; i < sd->channel_count; i++) { struct channel_data *chan = sd->channels[i]; |