chiark / gitweb /
Fix false-positive completion detection in X Solo.
authorSimon Tatham <anakin@pobox.com>
Sun, 25 Mar 2018 21:27:38 +0000 (22:27 +0100)
committerSimon Tatham <anakin@pobox.com>
Sun, 25 Mar 2018 21:27:38 +0000 (22:27 +0100)
Spotted by Michael Quevillon. After checking the set of digits
appearing in one of the two main grid diagonals, we weren't clearing
the used[] array before using it to check the same thing about the
other diagonal. So if the first diagonal we check has one of
everything, then the second will be misidentified as correct (for the
purposes of game-completion detection, although not error
highlighting) even if it doesn't have one of everything.

solo.c

diff --git a/solo.c b/solo.c
index dd04cdf281944b6ba7cd9612100ce4ee9b61fdb0..e72b14f48b46e85aeba288c3c573f83560cb63f0 100644 (file)
--- a/solo.c
+++ b/solo.c
@@ -3103,6 +3103,8 @@ static int check_valid(int cr, struct block_structure *blocks,
                sfree(used);
                return FALSE;
            }
+
+       memset(used, FALSE, cr);
        for (i = 0; i < cr; i++)
            if (grid[diag1(i)] > 0 && grid[diag1(i)] <= cr)
                used[grid[diag1(i)]-1] = TRUE;