correct bound checking

This commit is contained in:
Laurent Mazet 2021-04-28 22:40:47 +02:00
parent 71df36594d
commit 2e681a9c0b
1 changed files with 2 additions and 2 deletions

View File

@ -556,7 +556,7 @@ function handleCommand(cmdNumber, message, response) {
case "rack":
rack = game.getPlayerRack(playerName);
if (cmd.indexFrom > 6 || cmd.indexFrom < 0) {
if (cmd.indexFrom > rackLength - 1 || cmd.indexFrom < 0) {
reply(message, response, cmdNumber, {error: 1, reason: "Wrong indexFrom"});
return false;
}
@ -601,7 +601,7 @@ function handleCommand(cmdNumber, message, response) {
switch (cmd.to) {
case "rack":
if (cmd.indexTo < 0 || cmd.indexTo > 6) {
if (cmd.indexTo < 0 || cmd.indexTo > rackLength - 1) {
reply(message, response, cmdNumber, {error: 1, reason: "Wrong indexTo"});
return false;
}