fix: add out of bounds checks to tetris_intersect

This commit is contained in:
2025-09-09 21:57:58 +02:00
parent 1d39bb1507
commit 2da740a5eb

View File

@@ -62,7 +62,11 @@ int tetris_intersect(const u8 *restrict const *restrict rows, u8 tetromino, uint
uint *pos = (uint[8]){x, y, x, y, x, y, x, y};
uint *end = pos + 8;
tetris_get_blocks(tetromino, pos);
while (pos < end && !rows[*(pos + 1)][*pos]) pos += 2;
for (; pos < end; pos += 2) {
if (*(pos + 0) >= TET_WIDTH) break;
if (*(pos + 1) >= TET_HEIGHT) break;
if (rows[*(pos + 1)][*pos]) break;
}
return pos < end;
}