Fix a use after free in IrcChannel::remove_user
This commit is contained in:
@@ -37,11 +37,14 @@ IrcUser* IrcChannel::find_user(const std::string& name) const
|
|||||||
|
|
||||||
void IrcChannel::remove_user(const IrcUser* user)
|
void IrcChannel::remove_user(const IrcUser* user)
|
||||||
{
|
{
|
||||||
this->users.erase(std::remove_if(this->users.begin(), this->users.end(),
|
const auto nick = user->nick;
|
||||||
[user](const std::unique_ptr<IrcUser>& u)
|
const auto it = std::find_if(this->users.begin(), this->users.end(),
|
||||||
{
|
[nick](const std::unique_ptr<IrcUser>& u)
|
||||||
return user->nick == u->nick;
|
{
|
||||||
}), this->users.end());
|
return nick == u->nick;
|
||||||
|
});
|
||||||
|
if (it != this->users.end())
|
||||||
|
this->users.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IrcChannel::remove_all_users()
|
void IrcChannel::remove_all_users()
|
||||||
|
|||||||
Reference in New Issue
Block a user