ref: d71ac73d8a4397c35b21ec08388a1c6f94691b64
parent: d022a1c11c185027fad937cbe9cd2c318025ee04
author: Simon Tatham <anakin@pobox.com>
date: Tue Mar 17 14:12:33 EDT 2020
Mines: add validation for negative mine count. If this gets through validation, it causes an infinite loop after gameplay begins.
--- a/mines.c
+++ b/mines.c
@@ -258,6 +258,8 @@
*/
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";