mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Don't segfault on premature solve moves in Mines
If a save file contained a solve move as the first move, Mines would dereference a null pointer trying to look up the (at that point undetermined) mine locations. Now execute_move() politely returns NULL instead. This save file demonstrates the problem: SAVEFILE:41:Simon Tatham's Portable Puzzle Collection VERSION :1:1 GAME :5:Mines PARAMS :5:3x3n0 CPARAMS :5:3x3n0 DESC :127:r0,u,7a142789cabddc3fc4dcb7d2baa4a4937b33c9613ea870ac098e217981ad339930af585557d62048ea745d05b01475d9699596b394cc0adeebf0440a02 UI :2:D0 TIME :1:0 NSTATES :1:2 STATEPOS:1:2 SOLVE :1:S
This commit is contained in:
1
mines.c
1
mines.c
@ -2637,6 +2637,7 @@ static game_state *execute_move(const game_state *from, const char *move)
|
|||||||
if (!strcmp(move, "S")) {
|
if (!strcmp(move, "S")) {
|
||||||
int yy, xx;
|
int yy, xx;
|
||||||
|
|
||||||
|
if (!from->layout->mines) return NULL; /* Game not started. */
|
||||||
ret = dup_game(from);
|
ret = dup_game(from);
|
||||||
if (!ret->dead) {
|
if (!ret->dead) {
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user