From ea6fa67c8723c5ef0eb6380593d83abb8124f3cb Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Thu, 11 Apr 2019 13:49:08 +0300 Subject: [PATCH] Fix potential crash / data corruption in hud message --- cl_dll/message.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cl_dll/message.cpp b/cl_dll/message.cpp index ff8d97bf..a8665c9f 100644 --- a/cl_dll/message.cpp +++ b/cl_dll/message.cpp @@ -281,9 +281,12 @@ void CHudMessage::MessageDrawScan( client_textmessage_t *pMessage, float time ) while( *pText && *pText != '\n' ) { unsigned char c = *pText; - line[m_parms.lineLength] = c; - m_parms.width += gHUD.m_scrinfo.charWidths[c]; - m_parms.lineLength++; + if (m_parms.lineLength < sizeof(line)-1) + { + line[m_parms.lineLength] = c; + m_parms.width += gHUD.m_scrinfo.charWidths[c]; + m_parms.lineLength++; + } pText++; } pText++; // Skip LF