From 0ca1a1ca8ec5526ec89a1bc5549e48875987e211 Mon Sep 17 00:00:00 2001 From: Mika Kuoppala Date: Tue, 9 Jan 2024 01:18:17 +0200 Subject: [PATCH] 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]' --- src/trap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/trap.c b/src/trap.c index 85abbd574..1de2f3516 100644 --- a/src/trap.c +++ b/src/trap.c @@ -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)))