mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 16:05:44 -07:00
Mines: add validation for negative mine count.
If this gets through validation, it causes an infinite loop after gameplay begins.
This commit is contained in:
2
mines.c
2
mines.c
@ -258,6 +258,8 @@ static const char *validate_params(const game_params *params, bool full)
|
|||||||
*/
|
*/
|
||||||
if (full && params->unique && (params->w <= 2 || params->h <= 2))
|
if (full && params->unique && (params->w <= 2 || params->h <= 2))
|
||||||
return "Width and height must both be greater than two";
|
return "Width and height must both be greater than two";
|
||||||
|
if (params->n < 0)
|
||||||
|
return "Mine count may not be negative";
|
||||||
if (params->n > params->w * params->h - 9)
|
if (params->n > params->w * params->h - 9)
|
||||||
return "Too many mines for grid size";
|
return "Too many mines for grid size";
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user