Black Box: correct order of validation checks for "F" commands

It doesn't do much good to range-check an argument after using it as
an array index.
This commit is contained in:
Ben Harris
2023-01-08 10:03:10 +00:00
parent d5b8a20def
commit c2eedeedfe

View File

@ -1067,10 +1067,10 @@ static game_state *execute_move(const game_state *from, const char *move)
case 'F':
sscanf(move+1, "%d", &rangeno);
if (ret->exits[rangeno] != LASER_EMPTY)
goto badmove;
if (!RANGECHECK(ret, rangeno))
goto badmove;
if (ret->exits[rangeno] != LASER_EMPTY)
goto badmove;
fire_laser(ret, rangeno);
break;