aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2014-07-17 22:54:49 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2014-07-17 23:48:38 +0200
commit081b9f6bd20dc19edbed491c4e8d8cb24de0559d (patch)
treec26d5b47c773c2422bde7b8394b91be328cd887e
parentb1780e3efba9913f7f0011efa9e7dfc5bd65603a (diff)
downloadxK-081b9f6bd20dc19edbed491c4e8d8cb24de0559d.tar.gz
xK-081b9f6bd20dc19edbed491c4e8d8cb24de0559d.tar.xz
xK-081b9f6bd20dc19edbed491c4e8d8cb24de0559d.zip
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).
-rw-r--r--src/kike.c10
1 files 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);