aboutsummaryrefslogtreecommitdiff
path: root/filling.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2007-02-28 21:19:15 +0000
committerSimon Tatham <anakin@pobox.com>2007-02-28 21:19:15 +0000
commit9287d95d0810e6fc76625aa270ecdff297934c55 (patch)
treed3d43a32a15410a08e1df3b866ac3f56e8b3ad21 /filling.c
parentde5ccc9352d0156600c0ed1e87daac28015e8c01 (diff)
downloadpuzzles-9287d95d0810e6fc76625aa270ecdff297934c55.zip
puzzles-9287d95d0810e6fc76625aa270ecdff297934c55.tar.gz
puzzles-9287d95d0810e6fc76625aa270ecdff297934c55.tar.bz2
puzzles-9287d95d0810e6fc76625aa270ecdff297934c55.tar.xz
General cleanups patch from James H:
- missing static in filling.c - better robustness in execute_move() in filling.c - remove side effects in assert statements - remove rogue diagnostic in galaxies.c - remove // comment in map.c - add more stylus-friendly UI to Pattern - bias Unequal towards generating inequality clues rather than numeric [originally from svn r7344]
Diffstat (limited to 'filling.c')
-rw-r--r--filling.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/filling.c b/filling.c
index 1ce04eb..b9dff73 100644
--- a/filling.c
+++ b/filling.c
@@ -299,7 +299,7 @@ static game_state *new_game(midend *, game_params *, char *);
static void free_game(game_state *);
/* generate a random valid board; uses validate_board. */
-void make_board(int *board, int w, int h, random_state *rs) {
+static void make_board(int *board, int w, int h, random_state *rs) {
int *dsf;
const unsigned int sz = w * h;
@@ -974,9 +974,9 @@ static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
static game_state *execute_move(game_state *state, char *move)
{
game_state *new_state;
+ const int sz = state->shared->params.w * state->shared->params.h;
if (*move == 's') {
- const int sz = state->shared->params.w * state->shared->params.h;
int i = 0;
new_state = dup_game(state);
for (++move; i < sz; ++i) new_state->board[i] = move[i] - '0';
@@ -991,6 +991,7 @@ static game_state *execute_move(game_state *state, char *move)
value = strtol(move, &endptr, 0);
if (endptr == move) return NULL;
if (*endptr != '\0') return NULL;
+ if (i < 0 || i >= sz || value < 0 || value > 9) return NULL;
new_state = dup_game(state);
new_state->board[i] = value;
}