mirror of
https://github.com/3lswear/webserv.git
synced 2025-10-28 21:07:59 +03:00
fix: call free on unitialized client (fix double free)
This commit is contained in:
@@ -153,14 +153,12 @@ inline int Server::delete_fd(std::map<int, t_tmp_fd *> &map,
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
ret = epoll_ctl(_epoll_fd, EPOLL_CTL_DEL, it->first, NULL);
|
ret = epoll_ctl(_epoll_fd, EPOLL_CTL_DEL, it->first, NULL);
|
||||||
// delete map[fd];
|
|
||||||
delete it->second;
|
|
||||||
DBOUT << WARNING << getDebugTime() << OKCYAN
|
DBOUT << WARNING << getDebugTime() << OKCYAN
|
||||||
<< " deleting fd "
|
<< " deleting fd "
|
||||||
<< it->first
|
<< it->first
|
||||||
<< ENDL;
|
<< ENDL;
|
||||||
|
delete it->second;
|
||||||
close(it->first);
|
close(it->first);
|
||||||
delete client_map[it->first];
|
|
||||||
client_map.erase(it->first);
|
client_map.erase(it->first);
|
||||||
map.erase(it++);
|
map.erase(it++);
|
||||||
|
|
||||||
@@ -339,7 +337,10 @@ void Server::run(void)
|
|||||||
while (fd_it != vacant_fds.end())
|
while (fd_it != vacant_fds.end())
|
||||||
{
|
{
|
||||||
if (TimeToDie(fd_it->second->last_modif, LIFE_TIME))
|
if (TimeToDie(fd_it->second->last_modif, LIFE_TIME))
|
||||||
|
{
|
||||||
|
free(client_map[fd_it->first]);
|
||||||
delete_fd(vacant_fds, fd_it, client_map);
|
delete_fd(vacant_fds, fd_it, client_map);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
++fd_it;
|
++fd_it;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user