fix bind out of bounds / keystring misreading

This commit is contained in:
Inuyasha 2016-01-28 08:15:34 -08:00
parent 732c1a87f1
commit d76e21b546
2 changed files with 4 additions and 4 deletions

View File

@ -202,7 +202,7 @@ static void CONS_Bind_f(void)
}
key = G_KeyStringtoNum(COM_Argv(1));
if (!key)
if (key <= 0 || key >= NUMINPUTS)
{
CONS_Alert(CONS_NOTICE, M_GetText("Invalid key name\n"));
return;

View File

@ -1042,13 +1042,13 @@ INT32 G_KeyStringtoNum(const char *keystr)
if (!keystr[1] && keystr[0] > ' ' && keystr[0] <= 'z')
return keystr[0];
if (!strncmp(keystr, "KEY", 3) && keystr[3] >= '0' && keystr[3] <= '9')
return atoi(&keystr[3]);
for (j = 0; j < NUMKEYNAMES; j++)
if (!stricmp(keynames[j].name, keystr))
return keynames[j].keynum;
if (strlen(keystr) > 3)
return atoi(&keystr[3]);
return 0;
}