aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2023-04-02 14:10:31 +0100
committerSimon Tatham <anakin@pobox.com>2023-04-02 14:35:12 +0100
commit79561485919e0dc867b5c5190c00aa90c5112b37 (patch)
tree21bfa38f2138da4381cebf48ce3715ae6c65f067
parent2296d6f078f543f8c17d9f9181ec10bd228110f2 (diff)
downloadpuzzles-79561485919e0dc867b5c5190c00aa90c5112b37.zip
puzzles-79561485919e0dc867b5c5190c00aa90c5112b37.tar.gz
puzzles-79561485919e0dc867b5c5190c00aa90c5112b37.tar.bz2
puzzles-79561485919e0dc867b5c5190c00aa90c5112b37.tar.xz
hat-test: fix array underrun.
Having _checked_ whether a hat index in my four-colouring maps was -1, I then went ahead and used it as an array index anyway, oops!
-rw-r--r--auxiliary/hat-test.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/auxiliary/hat-test.c b/auxiliary/hat-test.c
index 8104161..4f25cc7 100644
--- a/auxiliary/hat-test.c
+++ b/auxiliary/hat-test.c
@@ -316,7 +316,9 @@ static inline FourColourMap fourcolourmap_update(
*/
for (i = 0; i < 4; i++) {
/* They should be the same metatile, so have same number of hats! */
- assert((f1[i] == -1) == (f2[i] == -1));
+ if (f1[i] == -1 && f2[i] == -1)
+ continue;
+ assert(f1[i] != -1 && f2[i] != -1);
if (f1[i] != 255)
newm.map[f2[i]] = prevm.map[f1[i]];