From 79561485919e0dc867b5c5190c00aa90c5112b37 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 2 Apr 2023 14:10:31 +0100 Subject: [PATCH] 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! --- auxiliary/hat-test.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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]];