From f31a400bac0b72e773e32d2a17ac839145dded2b Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Wed, 16 Aug 2017 11:37:10 -0400 Subject: puzzles: add more parameter validation checks Fixes some annoying crashes. Change-Id: If3c293bd90e301c3e697d1e5fcb1b0aa2ea320fb --- apps/plugins/puzzles/src/flood.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'apps/plugins/puzzles/src/flood.c') 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) -- cgit v1.1