summary refs log tree commit diff stats
path: root/src/common/outbound.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/outbound.c')
-rw-r--r--src/common/outbound.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/common/outbound.c b/src/common/outbound.c
index 42e2eeee..936e0ede 100644
--- a/src/common/outbound.c
+++ b/src/common/outbound.c
@@ -742,15 +742,25 @@ cmd_country (struct session *sess, char *tbuf, char *word[], char *word_eol[])
 static int
 cmd_cycle (struct session *sess, char *tbuf, char *word[], char *word_eol[])
 {
-	char *key = sess->channelkey;
+	char *key = NULL;
 	char *chan = word[2];
+	session *chan_sess;
+
 	if (!*chan)
 		chan = sess->channel;
-	if (*chan && sess->type == SESS_CHANNEL)
+
+	if (chan)
 	{
-		sess->server->p_cycle (sess->server, chan, key);
-		return TRUE;
+		chan_sess = find_channel (sess->server, chan);
+
+		if (chan_sess && chan_sess->type == SESS_CHANNEL)
+		{
+			key = chan_sess->channelkey;
+			sess->server->p_cycle (sess->server, chan, key);
+			return TRUE;
+		}
 	}
+
 	return FALSE;
 }