From 0381e6162459fe01038fbcdf279a1418796a4113 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Tue, 17 Dec 2024 18:22:52 +0200 Subject: [PATCH] Fix out-of-bounds in test_move Hero was on the top-left of an open map at (1,0), and a monster was trying to knock them back to (0,-1). --- src/hack.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/hack.c b/src/hack.c index 538a9b699..ed5475136 100644 --- a/src/hack.c +++ b/src/hack.c @@ -972,10 +972,16 @@ test_move( { coordxy x = ux + dx; coordxy y = uy + dy; - struct rm *tmpr = &levl[x][y]; + struct rm *tmpr; struct rm *ust; svc.context.door_opened = FALSE; + + if (!isok(x, y)) + return FALSE; + + tmpr = &levl[x][y]; + /* * Check for physical obstacles. First, the place we are going. */