chiark
/
gitweb
/
~ian
/
sgt-puzzles.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
d022a1c
)
Mines: add validation for negative mine count.
author
Simon Tatham
<anakin@pobox.com>
Tue, 17 Mar 2020 18:12:33 +0000
(18:12 +0000)
committer
Simon Tatham
<anakin@pobox.com>
Tue, 17 Mar 2020 18:12:33 +0000
(18:12 +0000)
If this gets through validation, it causes an infinite loop after
gameplay begins.
mines.c
patch
|
blob
|
history
diff --git
a/mines.c
b/mines.c
index 00d306c58dbf171060a1ea1d8c34d0b5395bae54..ee2d5bb621edcdda17f3aa69c45e5f5b307083a4 100644
(file)
--- a/
mines.c
+++ b/
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))
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)
return "Too many mines for grid size";