Skip to content

Commit

Permalink
fix(crash): idle users array out-of-bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
polonel committed Dec 6, 2018
1 parent 527b234 commit ebacda9
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/socketserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -628,11 +628,22 @@ var socketServer = function(ws) {
utils.sendToSelf(socket, '$trudesk:chat:updateOnlineBubbles', {sortedUserList: sortedUserList, sortedIdleList: sortedIdleList});
}
} else {
idleUsers[user.username].sockets.push(socket.id);
sortedUserList = _.fromPairs(_.sortBy(_.toPairs(usersOnline), function(o) { return o[0]; }));
sortedIdleList = _.fromPairs(_.sortBy(_.toPairs(idleUsers), function(o) { return o[0]; }));

utils.sendToSelf(socket, '$trudesk:chat:updateOnlineBubbles', {sortedUserList: sortedUserList, sortedIdleList: sortedIdleList});
var idleUser = idleUsers[user.username.toLowerCase()];
if (!_.isUndefined(idleUser)) {
idleUser.sockets.push(socket.id);

sortedUserList = _.fromPairs(_.sortBy(_.toPairs(usersOnline), function (o) {
return o[0];
}));
sortedIdleList = _.fromPairs(_.sortBy(_.toPairs(idleUsers), function (o) {
return o[0];
}));

utils.sendToSelf(socket, '$trudesk:chat:updateOnlineBubbles', {
sortedUserList: sortedUserList,
sortedIdleList: sortedIdleList
});
}
}
});

Expand Down

0 comments on commit ebacda9

Please sign in to comment.