aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Harris <bjh21@bjh21.me.uk>2023-01-31 21:08:05 +0000
committerBen Harris <bjh21@bjh21.me.uk>2023-02-05 21:00:00 +0000
commit49841bd0fc04490d94cf32c0e6f9d3f4ffabe098 (patch)
tree8d9c9330acc5f990320051b1842ac997131d1525
parentc0e08f308792b15425e10ad494263d77a45ad92d (diff)
downloadpuzzles-49841bd0fc04490d94cf32c0e6f9d3f4ffabe098.zip
puzzles-49841bd0fc04490d94cf32c0e6f9d3f4ffabe098.tar.gz
puzzles-49841bd0fc04490d94cf32c0e6f9d3f4ffabe098.tar.bz2
puzzles-49841bd0fc04490d94cf32c0e6f9d3f4ffabe098.tar.xz
Mines: Add assertions to range-check conversions to short
I think these should be adequately guarded by the new restrictions on grid size, but I'd prefer to be sure.
-rw-r--r--mines.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/mines.c b/mines.c
index c666001..04364e5 100644
--- a/mines.c
+++ b/mines.c
@@ -435,7 +435,9 @@ static void ss_add(struct setstore *ss, int x, int y, int mask, int mines)
* Create a set structure and add it to the tree.
*/
s = snew(struct set);
+ assert(SHRT_MIN <= x && x <= SHRT_MAX);
s->x = x;
+ assert(SHRT_MIN <= y && y <= SHRT_MAX);
s->y = y;
s->mask = mask;
s->mines = mines;
@@ -506,7 +508,9 @@ static struct set **ss_overlap(struct setstore *ss, int x, int y, int mask)
/*
* Find the first set with these top left coordinates.
*/
+ assert(SHRT_MIN <= xx && xx <= SHRT_MAX);
stmp.x = xx;
+ assert(SHRT_MIN <= yy && yy <= SHRT_MAX);
stmp.y = yy;
stmp.mask = 0;