diff options
| author | Ben Harris <bjh21@bjh21.me.uk> | 2023-01-28 19:34:28 +0000 |
|---|---|---|
| committer | Ben Harris <bjh21@bjh21.me.uk> | 2023-01-28 19:34:28 +0000 |
| commit | 28671e76b736aeb860b1f725898c45fe70ae6212 (patch) | |
| tree | 55942de41d815d81abb38bfd5c8f468a0beac273 /mines.c | |
| parent | e4112b322e299a461ddc46daee741c73733e186d (diff) | |
| download | puzzles-28671e76b736aeb860b1f725898c45fe70ae6212.zip puzzles-28671e76b736aeb860b1f725898c45fe70ae6212.tar.gz puzzles-28671e76b736aeb860b1f725898c45fe70ae6212.tar.bz2 puzzles-28671e76b736aeb860b1f725898c45fe70ae6212.tar.xz | |
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
Diffstat (limited to 'mines.c')
| -rw-r--r-- | mines.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -2637,6 +2637,7 @@ static game_state *execute_move(const game_state *from, const char *move) if (!strcmp(move, "S")) { int yy, xx; + if (!from->layout->mines) return NULL; /* Game not started. */ ret = dup_game(from); if (!ret->dead) { /* |