Prevent out of array access

As index() can match with the string terminator, that would make
the xdir etc array references out of bounds.
This commit is contained in:
Pasi Kallinen
2015-11-01 01:32:20 +02:00
parent b0e4357c32
commit 4f616a932c

View File

@@ -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];