aboutsummaryrefslogtreecommitdiffstats
path: root/irc_commands.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2010-07-28 00:24:59 +0200
committerWilmer van der Gaast <wilmer@gaast.net>2010-07-28 00:24:59 +0200
commit13fa2db53edbeae0d4638db1de042b8f415f8871 (patch)
tree229b3ec89de1af9f9aa06b5a7963ca921606bae5 /irc_commands.c
parent42553208d714b80a2a64d334f1659ec379042f8b (diff)
Don't crash when trying to join a channel with an invalid name.
Diffstat (limited to 'irc_commands.c')
-rw-r--r--irc_commands.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/irc_commands.c b/irc_commands.c
index 0fda9669..2601cb9c 100644
--- a/irc_commands.c
+++ b/irc_commands.c
@@ -139,10 +139,9 @@ static void irc_cmd_join( irc_t *irc, char **cmd )
if( ( comma = strchr( s, ',' ) ) )
*comma = '\0';
- if( ( ic = irc_channel_by_name( irc, s ) ) == NULL )
+ if( ( ic = irc_channel_by_name( irc, s ) ) == NULL &&
+ ( ic = irc_channel_new( irc, s ) ) )
{
- ic = irc_channel_new( irc, s );
-
if( strcmp( set_getstr( &ic->set, "type" ), "control" ) != 0 )
{
/* Autoconfiguration is for control channels only ATM. */
@@ -162,11 +161,13 @@ static void irc_cmd_join( irc_t *irc, char **cmd )
}
else
{
+ /* The set commands above will run this already,
+ but if we didn't hit any, we have to fill the
+ channel with the default population. */
bee_irc_channel_update( ic->irc, ic, NULL );
}
}
-
- if( ic == NULL )
+ else if( ic == NULL )
{
irc_send_num( irc, 479, "%s :Invalid channel name", s );
goto next;