Correct a range check in Magnets' layout verification

Squares in the grid are numbered from 0, so the upper limit check
needs to use "<=" rather than "<".  Without this, invalid descriptions
can cause a read overrun off the end of the board.
This commit is contained in:
Ben Harris
2023-03-31 20:38:31 +01:00
parent 1af1204b9c
commit 91735e5019

View File

@ -520,7 +520,7 @@ nextchar:
* (i.e. each end points to the other) */
for (idx = 0; idx < state->wh; idx++) {
if (state->common->dominoes[idx] < 0 ||
state->common->dominoes[idx] > state->wh ||
state->common->dominoes[idx] >= state->wh ||
state->common->dominoes[state->common->dominoes[idx]] != idx) {
*prob = "Domino descriptions inconsistent";
goto done;