mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Inertia: insist that solutions must be non-empty
Any solution actually generated by the solver will contain at least one move, because it refuses to solve games that are already solved. However, a save file might contain an empty "solve" move. This causes an uninitialised read when execute_move() then tries to check if the next move is in accordance with the solution, because the check for running off the end of the solution happens after that. We now avoid this by treating a zero-length "solution" as an invalid move.
This commit is contained in:
@ -1697,6 +1697,7 @@ static game_state *execute_move(const game_state *state, const char *move)
|
|||||||
* This is a solve move, so we don't actually _change_ the
|
* This is a solve move, so we don't actually _change_ the
|
||||||
* grid but merely set up a stored solution path.
|
* grid but merely set up a stored solution path.
|
||||||
*/
|
*/
|
||||||
|
if (move[1] == '\0') return NULL; /* Solution must be non-empty. */
|
||||||
ret = dup_game(state);
|
ret = dup_game(state);
|
||||||
install_new_solution(ret, move);
|
install_new_solution(ret, move);
|
||||||
return ret;
|
return ret;
|
||||||
|
Reference in New Issue
Block a user