From f20e99ac0a4eca9e4f70bd6bf5625f9563a5aee6 Mon Sep 17 00:00:00 2001 From: copperwater Date: Sat, 25 Sep 2021 19:03:51 -0400 Subject: [PATCH] Fix out-of-bounds access of xdir and ydir in farlook In commit db68395, most of the instances of xdir and ydir here were changed to u.dx and u.dy, but not all of them. The remaining ones are out-of-bounds on xdir and ydir, because i is always set to 12 from an earlier loop and is no longer involved in handling user input. They should be u.dx and u.dy like the rest. --- src/do_name.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/do_name.c b/src/do_name.c index e8a727db6..818fa41b8 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -787,9 +787,8 @@ getpos(coord *ccp, boolean force, const char *goal) dy = u.dy; while (isok(cx + dx, cy + dy) && glyph == glyph_at(cx + dx, cy + dy) - && isok(cx + dx + xdir[i], cy + dy + ydir[i]) - && glyph == glyph_at(cx + dx + xdir[i], - cy + dy + ydir[i])) { + && isok(cx + dx + u.dx, cy + dy + u.dy) + && glyph == glyph_at(cx + dx + u.dx, cy + dy + u.dy)) { dx += u.dx; dy += u.dy; -- 2.50.1