Same Game: reject moves with unexpected characters in

Previously if a move string starting with "M" contained anything else
other than a digit or a comma, execute_move() would spin trying to
parse it.  Now it returns NULL.
This commit is contained in:
Ben Harris
2023-01-07 23:24:39 +00:00
parent 0dbbd52935
commit 8c5279cf75

View File

@ -1346,6 +1346,10 @@ static game_state *execute_move(const game_state *from, const char *move)
move++; move++;
while (*move) { while (*move) {
if (!isdigit((unsigned char)*move)) {
free_game(ret);
return NULL;
}
i = atoi(move); i = atoi(move);
if (i < 0 || i >= ret->n) { if (i < 0 || i >= ret->n) {
free_game(ret); free_game(ret);