From 4f616a932c1e56f1b4aec38420593375630bc267 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Sun, 1 Nov 2015 01:32:20 +0200 Subject: [PATCH] Prevent out of array access As index() can match with the string terminator, that would make the xdir etc array references out of bounds. --- src/cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd.c b/src/cmd.c index 6cf2363a3..5bcd57fa5 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -3472,7 +3472,7 @@ char sym; register const char *dp = index(Cmd.dirchars, sym); u.dz = 0; - if (!dp) + if (!dp || !*dp) return 0; u.dx = xdir[dp - Cmd.dirchars]; u.dy = ydir[dp - Cmd.dirchars];