From a127045d98340ab8d21c7e6517ce04b5f06096ca Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 22 Jan 2020 22:19:00 -0800 Subject: [PATCH 1/2] 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)) From 128f0757b66f931956db15382667e5126d7e1536 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 23 Jan 2020 13:57:39 -0800 Subject: [PATCH 2/2] Semantics --- src/g_input.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/g_input.c b/src/g_input.c index 2efae9cf3..ed7bc5cb6 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -667,8 +667,7 @@ INT32 G_KeyStringtoNum(const char *keystr) j = atoi(&keystr[3]); if (j < NUMINPUTS) return j; - else - return 0; + return 0; } for (j = 0; j < NUMKEYNAMES; j++)