ref: c2eedeedfe3c48f3f013fb1308f61d7ef94e8b2c
parent: d5b8a20def7634d4df79800fe54d8e34c6353974
author: Ben Harris <[email protected]>
date: Sun Jan 8 05:03:10 EST 2023
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.
--- a/blackbox.c
+++ b/blackbox.c
@@ -1067,9 +1067,9 @@
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;