diff options
| author | Franklin Wei <git@fwei.tk> | 2017-08-16 11:37:10 -0400 |
|---|---|---|
| committer | Franklin Wei <git@fwei.tk> | 2017-08-16 11:40:42 -0400 |
| commit | f31a400bac0b72e773e32d2a17ac839145dded2b (patch) | |
| tree | dc812d909b41fe51870b568cc5e4cb2315b95c7c /apps/plugins/puzzles/src/flood.c | |
| parent | c78ff7f6153d2a787bfd8cb3410dff8db74b2789 (diff) | |
| download | rockbox-f31a400bac0b72e773e32d2a17ac839145dded2b.zip rockbox-f31a400bac0b72e773e32d2a17ac839145dded2b.tar.gz rockbox-f31a400bac0b72e773e32d2a17ac839145dded2b.tar.bz2 rockbox-f31a400bac0b72e773e32d2a17ac839145dded2b.tar.xz | |
puzzles: add more parameter validation checks
Fixes some annoying crashes.
Change-Id: If3c293bd90e301c3e697d1e5fcb1b0aa2ea320fb
Diffstat (limited to 'apps/plugins/puzzles/src/flood.c')
| -rw-r--r-- | apps/plugins/puzzles/src/flood.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/apps/plugins/puzzles/src/flood.c b/apps/plugins/puzzles/src/flood.c index 1262be8..59e160c 100644 --- a/apps/plugins/puzzles/src/flood.c +++ b/apps/plugins/puzzles/src/flood.c @@ -213,8 +213,10 @@ static game_params *custom_params(const config_item *cfg) static char *validate_params(const game_params *params, int full) { - if (params->w < 2 && params->h < 2) + if (params->w * params->h < 2) return "Grid must contain at least two squares"; + if (params->w < 1 || params->h < 1) + return "Width and height must both be at least one"; if (params->colours < 3 || params->colours > 10) return "Must have between 3 and 10 colours"; if (params->leniency < 0) |