From 18a479a308ffa79aa35fdcf8c2e0416ed35a8642 Mon Sep 17 00:00:00 2001 From: Kp Date: Thu, 25 Aug 2016 04:05:31 +0000 Subject: [PATCH] Change multi_send_macro to handle invalid inputs No caller passes a key value other than [KEY_F9, KEY_F12]. If one did, an invalid array reference would occur. Restructure the code to return on invalid inputs. This fixes a flow control analysis warning. --- similar/main/multi.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/similar/main/multi.cpp b/similar/main/multi.cpp index 2445ad189..36e8c5b58 100644 --- a/similar/main/multi.cpp +++ b/similar/main/multi.cpp @@ -1260,13 +1260,13 @@ static void multi_message_feedback(void) } } -void -multi_send_macro(int key) +void multi_send_macro(const int fkey) { if (! (Game_mode & GM_MULTI) ) return; - switch(key) + unsigned key; + switch (fkey) { case KEY_F9: key = 0; break; @@ -1278,6 +1278,7 @@ multi_send_macro(int key) key = 3; break; default: Int3(); + return; } if (!PlayerCfg.NetworkMessageMacro[key][0])