src/trap: Fix isclearpath out of bound access on levl array

Do isok check apriori to accessing the levl array to filter
out dx/dy that have grown too large.

This fixes:
trap.c:3455:19: runtime error: index 80 out of bounds for type 'rm [80][21]'
This commit is contained in:
Mika Kuoppala
2024-01-09 01:18:17 +02:00
parent eec2abcc96
commit 0ca1a1ca8e

View File

@@ -3452,8 +3452,10 @@ isclearpath(
while (distance-- > 0) {
x += dx;
y += dy;
if (!isok(x, y))
return FALSE;
typ = levl[x][y].typ;
if (!isok(x, y) || !ZAP_POS(typ) || closed_door(x, y))
if (!ZAP_POS(typ) || closed_door(x, y))
return FALSE;
if ((t = t_at(x, y)) != 0
&& (is_pit(t->ttyp) || is_hole(t->ttyp) || is_xport(t->ttyp)))