~singpolyma/biboumi

57263961b487bd839cbce5fe7547933240792fbc — louiz’ 7 years ago c1f678e
Fix a use after free in IrcChannel::remove_user
1 files changed, 8 insertions(+), 5 deletions(-)

M src/irc/irc_channel.cpp
M src/irc/irc_channel.cpp => src/irc/irc_channel.cpp +8 -5
@@ 37,11 37,14 @@ IrcUser* IrcChannel::find_user(const std::string& name) const

void IrcChannel::remove_user(const IrcUser* user)
{
  this->users.erase(std::remove_if(this->users.begin(), this->users.end(),
                    [user](const std::unique_ptr<IrcUser>& u)
                    {
                      return user->nick == u->nick;
                    }), this->users.end());
  const auto nick = user->nick;
  const auto it = std::find_if(this->users.begin(), this->users.end(),
                               [nick](const std::unique_ptr<IrcUser>& u)
                               {
                                 return nick == u->nick;
                               });
  if (it != this->users.end())
    this->users.erase(it);
}

void IrcChannel::remove_all_users()