Fix corner case causing TypeError in userJoin
I believe this issue was caused by a single user in the channel being kicked for a duplicate login, thereby unloading the channel while the for loop was iterating, so this.users became undefined before the loop exited and thus there was a TypeError for reading this.users.length
This commit is contained in:
parent
df16458f98
commit
3460b0544c
|
@ -881,16 +881,16 @@ Channel.prototype.userJoin = function(user, password) {
|
|||
Logger.errlog.log("keys: " + Object.keys(this).join(","));
|
||||
return;
|
||||
}
|
||||
for(var i = 0; i < this.users.length; i++) {
|
||||
if(this.users[i].name.toLowerCase() == user.name.toLowerCase()) {
|
||||
if (this.users[i] == user) {
|
||||
this.users.forEach(function (u) {
|
||||
if(u.name.toLowerCase() == user.name.toLowerCase()) {
|
||||
if (u == user) {
|
||||
Logger.errlog.log("Wat: userJoin() called on user "+
|
||||
"already in the channel");
|
||||
break;
|
||||
return;
|
||||
}
|
||||
this.kick(this.users[i], "Duplicate login");
|
||||
this.kick(u, "Duplicate login");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.users.push(user);
|
||||
|
|
Loading…
Reference in a new issue