Skip to content

Commit 976b434

Browse files
author
Pavel Kovalenko
committed
Fix potential stack overflow in CConsole::add_internal_cmds.
1 parent 7dc1f10 commit 976b434

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/xrEngine/XR_IOConsole.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -765,20 +765,17 @@ bool CConsole::add_internal_cmds( LPCSTR in_str, vecTipsEx& out_v )
765765

766766
bool res = false;
767767
// word in begin
768+
xr_string name2;
768769
vecCMD_IT itb = Commands.begin();
769770
vecCMD_IT ite = Commands.end();
770771
for ( ; itb != ite; ++itb )
771772
{
772773
LPCSTR name = itb->first;
773774
u32 name_sz = xr_strlen(name);
774-
PSTR name2 = (PSTR)_alloca( (name_sz+1) * sizeof(char) );
775-
776775
if ( name_sz >= in_sz )
777776
{
778-
strncpy_s( name2, name_sz+1, name, in_sz );
779-
name2[in_sz] = 0;
780-
781-
if ( !stricmp( name2, in_str ) )
777+
name2.assign(name, in_sz);
778+
if ( !stricmp( name2.c_str(), in_str ) )
782779
{
783780
shared_str temp;
784781
temp._set( name );

0 commit comments

Comments
 (0)