summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog.adoc1
-rw-r--r--src/plugins/irc/irc-server.c9
-rw-r--r--tests/unit/plugins/irc/test-irc-server.cpp4
3 files changed, 12 insertions, 2 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc
index 35b270596..2165b202d 100644
--- a/ChangeLog.adoc
+++ b/ChangeLog.adoc
@@ -45,6 +45,7 @@ Bug fixes::
* core: fix decoding of attributes in basic ANSI colors (issue #1678)
* api: fix function string_match with joker in the string if multiple words matched in input string
+ * irc: fix send of empty JOIN when connecting to a server with only parted channels (issue #1638)
* irc: fix SASL authentication when AUTHENTICATE message is received with a server name (issue #1679)
* irc: remove unneeded message about Diffie-Hellman shared secret exchange during SSL connection to server (issue #857)
* irc: escape/unescape IRC message tags values (issue #1654)
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index 75519fb0e..a0d27bc86 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -5519,6 +5519,8 @@ irc_server_autojoin_create_buffers (struct t_irc_server *server)
*
* #channel1,#channel2,#channel3 key1,key2
*
+ * Returns NULL if no channels have been found.
+ *
* Note: result must be freed after use.
*/
@@ -5527,6 +5529,7 @@ irc_server_build_autojoin (struct t_irc_server *server)
{
struct t_irc_channel *ptr_channel;
char **channels_with_key, **channels_others, **keys;
+ int num_channels;
channels_with_key = NULL;
channels_others = NULL;
@@ -5542,6 +5545,8 @@ irc_server_build_autojoin (struct t_irc_server *server)
if (!keys)
goto error;
+ num_channels = 0;
+
for (ptr_channel = server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
@@ -5569,9 +5574,13 @@ irc_server_build_autojoin (struct t_irc_server *server)
ptr_channel->name,
-1);
}
+ num_channels++;
}
}
+ if (num_channels == 0)
+ goto error;
+
/*
* concatenate channels_with_key + channels_others + keys
* into channels_with_key
diff --git a/tests/unit/plugins/irc/test-irc-server.cpp b/tests/unit/plugins/irc/test-irc-server.cpp
index d891d3ea0..2446f2905 100644
--- a/tests/unit/plugins/irc/test-irc-server.cpp
+++ b/tests/unit/plugins/irc/test-irc-server.cpp
@@ -1088,7 +1088,7 @@ TEST(IrcServerConnected, BuildAutojoin)
server_recv (":server 001 alice");
- WEE_TEST_STR("", irc_server_build_autojoin (ptr_server));
+ POINTERS_EQUAL(NULL, irc_server_build_autojoin (ptr_server));
/* join one channel */
server_recv (":alice!user@host JOIN #test1");
@@ -1096,7 +1096,7 @@ TEST(IrcServerConnected, BuildAutojoin)
/* simulate a "parted" channel */
ptr_server->channels->part = 1;
- WEE_TEST_STR("", irc_server_build_autojoin (ptr_server));
+ POINTERS_EQUAL(NULL, irc_server_build_autojoin (ptr_server));
/* restore "part" flag */
ptr_server->channels->part = 0;