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!
This commit is contained in:
Simon Tatham
2023-04-02 14:10:31 +01:00
parent 2296d6f078
commit 7956148591

View File

@ -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]];