Don't set controls to keys out of array bounds

Shout-out to TAG's config that somehow had
`setcontrol2 "custom3" "KEY931926528"`, cuasing the game to crash only in
Splitscreen.
This commit is contained in:
James R 2020-01-22 22:19:00 -08:00
parent a6d49eaaa7
commit f0daea39d4
1 changed files with 8 additions and 1 deletions

View File

@ -662,7 +662,14 @@ INT32 G_KeyStringtoNum(const char *keystr)
return keystr[0];
if (!strncmp(keystr, "KEY", 3) && keystr[3] >= '0' && keystr[3] <= '9')
return atoi(&keystr[3]);
{
/* what if we out of range bruh? */
j = atoi(&keystr[3]);
if (j < NUMINPUTS)
return j;
else
return 0;
}
for (j = 0; j < NUMKEYNAMES; j++)
if (!stricmp(keynames[j].name, keystr))