segfault in function JOIN Fixed

This commit is contained in:
Samy BEN TAYEB 2025-06-18 00:20:54 +02:00
parent 2b3b6654e7
commit 150ada2f4e
4 changed files with 13 additions and 15 deletions

View file

@ -6,7 +6,7 @@
/* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/20 22:43:24 by rparodi #+# #+# */
/* Updated: 2025/06/17 23:51:54 by sben-tay ### ########.fr */
/* Updated: 2025/06/18 00:10:48 by sben-tay ### ########.fr */
/* */
/* ************************************************************************** */
@ -48,7 +48,7 @@ User *Channel::getOwner() const {
*
* @return list of Users in the channel
*/
std::list<User *> Channel::getUsers() const {
std::list<User *>& Channel::getUsers() {
return this->_users;
}

View file

@ -6,7 +6,7 @@
/* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */
/* Updated: 2025/06/17 23:50:28 by sben-tay ### ########.fr */
/* Updated: 2025/06/17 23:55:31 by sben-tay ### ########.fr */
/* */
/* ************************************************************************** */
@ -89,5 +89,4 @@ void Join::execute() {
msg353 += (*it)->getNickname() + " ";
}
_cTarget->sendAllClientInAChannel(msgJoin + msg332 + msg353 + "\r\n");
}
}

View file

@ -6,7 +6,7 @@
/* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/13 11:11:07 by rparodi #+# #+# */
/* Updated: 2025/06/17 23:16:55 by sben-tay ### ########.fr */
/* Updated: 2025/06/18 00:10:14 by sben-tay ### ########.fr */
/* */
/* ************************************************************************** */
@ -185,7 +185,6 @@ void Server::printUsers() const
std::string Server::getPassword() const { return this->_password; }
std::list<User *> Server::getUsersList() const {
// to_delete when done
WARNING_MSG("TO DO FILL")
std::list<User*> userList;
for (std::map<int, User*>::const_iterator it = _users.begin(); it != _users.end(); ++it) {
@ -212,10 +211,10 @@ std::vector<std::string> splitLines(const std::string& input) {
}
void Server::disconnectClient(int fd) {
_pollManager.removeClient(fd);
close(fd);
if (_users.count(fd)) {
delete _users[fd];
_users.erase(fd);
}
User *user = _users[fd];
for (std::list<Channel*>::iterator it = _channels.begin(); it != _channels.end(); ++it)
(*it)->removeUser(user);
delete user;
_users.erase(fd);
}