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).
This commit is contained in:
Přemysl Eric Janouch 2014-07-17 22:54:49 +02:00
parent b1780e3efb
commit 081b9f6bd2

View File

@ -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);