ref: 28671e76b736aeb860b1f725898c45fe70ae6212
parent: e4112b322e299a461ddc46daee741c73733e186d
author: Ben Harris <[email protected]>
date: Sat Jan 28 14:34:28 EST 2023
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
--- a/mines.c
+++ b/mines.c
@@ -2637,6 +2637,7 @@
if (!strcmp(move, "S")) {
int yy, xx;
+ if (!from->layout->mines) return NULL; /* Game not started. */
ret = dup_game(from);
if (!ret->dead) {
/*