From 081b9f6bd20dc19edbed491c4e8d8cb24de0559d Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Thu, 17 Jul 2014 22:54:49 +0200
Subject: Fix handling of multiple NICK's before a USER
We have to release the old nickname _first_, so that we can register the
same one again (albeit with a slight race condition).
---
src/kike.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/kike.c b/src/kike.c
index 1b218c9..07ebccd 100644
--- a/src/kike.c
+++ b/src/kike.c
@@ -638,16 +638,16 @@ irc_handle_nick (const struct irc_message *msg, struct client *c)
irc_send_reply (c, IRC_ERR_ERRONEOUSNICKNAME, nickname);
return;
}
- if (str_map_find (&ctx->users, nickname))
- {
- irc_send_reply (c, IRC_ERR_NICKNAMEINUSE, nickname);
- return;
- }
if (c->nickname)
{
str_map_set (&ctx->users, c->nickname, NULL);
free (c->nickname);
}
+ if (str_map_find (&ctx->users, nickname))
+ {
+ irc_send_reply (c, IRC_ERR_NICKNAMEINUSE, nickname);
+ return;
+ }
// Allocate the nickname
c->nickname = xstrdup (nickname);
--
cgit v1.2.3-70-g09d2