Fixed if using splice in loop should always decrement index or might out of array range
This commit is contained in:
parent
3683a6dd34
commit
332413bcaa
2 changed files with 12 additions and 4 deletions
|
@ -264,8 +264,10 @@ function finishConnection(socket, note, user) {
|
||||||
|
|
||||||
//clear finished socket in queue
|
//clear finished socket in queue
|
||||||
for (var i = 0; i < connectionSocketQueue.length; i++) {
|
for (var i = 0; i < connectionSocketQueue.length; i++) {
|
||||||
if (!connectionSocketQueue[i] || connectionSocketQueue[i].id == socket.id)
|
if (!connectionSocketQueue[i] || connectionSocketQueue[i].id == socket.id) {
|
||||||
connectionSocketQueue.splice(i, 1);
|
connectionSocketQueue.splice(i, 1);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//seek for next socket
|
//seek for next socket
|
||||||
isConnectionBusy = false;
|
isConnectionBusy = false;
|
||||||
|
@ -302,8 +304,10 @@ function startConnection(socket) {
|
||||||
socket.disconnect(true);
|
socket.disconnect(true);
|
||||||
//clear err socket in queue
|
//clear err socket in queue
|
||||||
for (var i = 0; i < connectionSocketQueue.length; i++) {
|
for (var i = 0; i < connectionSocketQueue.length; i++) {
|
||||||
if (!connectionSocketQueue[i] || connectionSocketQueue[i].id == socket.id)
|
if (!connectionSocketQueue[i] || connectionSocketQueue[i].id == socket.id) {
|
||||||
connectionSocketQueue.splice(i, 1);
|
connectionSocketQueue.splice(i, 1);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
isConnectionBusy = false;
|
isConnectionBusy = false;
|
||||||
return logger.error(err);
|
return logger.error(err);
|
||||||
|
@ -390,8 +394,10 @@ function disconnect(socket) {
|
||||||
|
|
||||||
//clear finished socket in queue
|
//clear finished socket in queue
|
||||||
for (var i = 0; i < disconnectSocketQueue.length; i++) {
|
for (var i = 0; i < disconnectSocketQueue.length; i++) {
|
||||||
if (!disconnectSocketQueue[i] || disconnectSocketQueue[i].id == socket.id)
|
if (!disconnectSocketQueue[i] || disconnectSocketQueue[i].id == socket.id) {
|
||||||
disconnectSocketQueue.splice(i, 1);
|
disconnectSocketQueue.splice(i, 1);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//seek for next socket
|
//seek for next socket
|
||||||
isDisconnectBusy = false;
|
isDisconnectBusy = false;
|
||||||
|
|
|
@ -123,8 +123,10 @@ function addHistory(id, text, time, tags, notehistory) {
|
||||||
|
|
||||||
function removeHistory(id, notehistory) {
|
function removeHistory(id, notehistory) {
|
||||||
for (var i = 0; i < notehistory.length; i++) {
|
for (var i = 0; i < notehistory.length; i++) {
|
||||||
if (notehistory[i].id == id)
|
if (notehistory[i].id == id) {
|
||||||
notehistory.splice(i, 1);
|
notehistory.splice(i, 1);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return notehistory;
|
return notehistory;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue