From 6ebc41a5543a2ea794a8256670e571c3ffb022bb Mon Sep 17 00:00:00 2001
From: mazmazz <mar.marcoz@outlook.com>
Date: Sun, 23 Dec 2018 02:25:58 -0500
Subject: [PATCH] Check target < MAXPLAYERS before PM

---
 src/hu_stuff.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/hu_stuff.c b/src/hu_stuff.c
index dca4a491c8..ee7d84096f 100644
--- a/src/hu_stuff.c
+++ b/src/hu_stuff.c
@@ -490,7 +490,7 @@ static void DoSayCommand(SINT8 target, size_t usedargs, UINT8 flags)
 		//CONS_Printf("%d\n", target);
 
 		// check for target player, if it doesn't exist then we can't send the message!
-		if (playeringame[target]) // player exists
+		if (target < MAXPLAYERS && playeringame[target]) // player exists
 			target++; // even though playernums are from 0 to 31, target is 1 to 32, so up that by 1 to have it work!
 		else
 		{
@@ -1014,7 +1014,7 @@ static void HU_queueChatChar(char c)
 			//CONS_Printf("%d\n", target);
 
 			// check for target player, if it doesn't exist then we can't send the message!
-			if (playeringame[target]) // player exists
+			if (target < MAXPLAYERS && playeringame[target]) // player exists
 				target++; // even though playernums are from 0 to 31, target is 1 to 32, so up that by 1 to have it work!
 			else
 			{
-- 
GitLab