From ae73ad76ef95f0e40868436cb750126322051dd0 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Sat, 4 Feb 2023 16:50:55 +0000 Subject: [PATCH] Range: Don't fail an assertion on an all-black board If there are no white squares, then Range's check that all the white squares form a connected component goes wrong. Skip the check in that case to avoid an assretion violation ("edsf_canonify: Assertion `index >= 0' failed."). This can be demonstrated by starting a game with no clues (e.g. "range 3:i") and then filling in every square. --- range.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/range.c b/range.c index bc70c05..c360b75 100644 --- a/range.c +++ b/range.c @@ -1494,7 +1494,8 @@ static bool find_errors(const game_state *state, bool *report) if (state->grid[r*w+c] != BLACK && state->grid[r*w+(c+1)] != BLACK) dsf_merge(dsf, r*w+c, r*w+(c+1)); - if (nblack + dsf_size(dsf, any_white_cell) < n) { + if (any_white_cell != -1 && + nblack + dsf_size(dsf, any_white_cell) < n) { int biggest, canonical; if (!report) {