From f0daea39d43d1a3cd54385474dd6c27e65da2e4c Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 22 Jan 2020 22:19:00 -0800 Subject: [PATCH] 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. --- src/g_input.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/g_input.c b/src/g_input.c index ac901703f..2efae9cf3 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -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))