diff options
| author | Ben Harris <bjh21@bjh21.me.uk> | 2023-01-11 23:11:46 +0000 |
|---|---|---|
| committer | Ben Harris <bjh21@bjh21.me.uk> | 2023-01-15 16:24:27 +0000 |
| commit | d71bba1a17d6b228e7dd8b437dccbd3f6bc4698c (patch) | |
| tree | 0d4f0eced96f0947d00f57b6291b019b7b9034de /loopy.c | |
| parent | fcda12f4b73e69841fd8957b8e33930c584093e5 (diff) | |
| download | puzzles-d71bba1a17d6b228e7dd8b437dccbd3f6bc4698c.zip puzzles-d71bba1a17d6b228e7dd8b437dccbd3f6bc4698c.tar.gz puzzles-d71bba1a17d6b228e7dd8b437dccbd3f6bc4698c.tar.bz2 puzzles-d71bba1a17d6b228e7dd8b437dccbd3f6bc4698c.tar.xz | |
Limit maximum grid size in Loopy
Every grid shape has its own limit, so this involved adding a new
interface between loopy.c and grid.c. The limits are based on ensuring
that the co-ordinate system of the grid doesn't overflow INT_MAX and
neither do the lengths of the face and dot arrays.
Though now I come to look at it I think the actual limits of grid.c are
much lower. Hmm.
Diffstat (limited to 'loopy.c')
| -rw-r--r-- | loopy.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -684,6 +684,7 @@ static game_params *custom_params(const config_item *cfg) static const char *validate_params(const game_params *params, bool full) { + const char *err; if (params->type < 0 || params->type >= NUM_GRID_TYPES) return "Illegal grid type"; if (params->w < grid_size_limits[params->type].amin || @@ -692,6 +693,8 @@ static const char *validate_params(const game_params *params, bool full) if (params->w < grid_size_limits[params->type].omin && params->h < grid_size_limits[params->type].omin) return grid_size_limits[params->type].oerr; + err = grid_validate_params(grid_types[params->type], params->w, params->h); + if (err != NULL) return err; /* * This shouldn't be able to happen at all, since decode_params |