From bf0062066d4168467df7d70bca8eb81289436940 Mon Sep 17 00:00:00 2001
From: nillerusr <nillerusr@gmail.com>
Date: Wed, 22 Jun 2022 19:11:55 +0300
Subject: [PATCH] engine: fix config executing

---
 engine/cmd.cpp | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/engine/cmd.cpp b/engine/cmd.cpp
index b9567271..8a507e46 100644
--- a/engine/cmd.cpp
+++ b/engine/cmd.cpp
@@ -624,12 +624,13 @@ void Cmd_Exec_f( const CCommand &args )
 		}
 	}
 
-	static char buf[16384] = { 0 };
+	char *buf = new char[16384];
 	int len = 0;
-	char *f = (char *)COM_LoadStackFile( fileName, buf, sizeof( buf ), len );
+	char *f = (char *)COM_LoadStackFile( fileName, buf, 16384, len );
 	if ( !f )
 	{
 		ConMsg( "exec: couldn't exec %s\n", szFile );
+		delete[] buf;
 		return;
 	}
 
@@ -645,7 +646,7 @@ void Cmd_Exec_f( const CCommand &args )
 	ConDMsg( "execing %s\n", szFile );
 
 	// check to make sure we're not going to overflow the cmd_text buffer
-    CommandHandle_t hCommand = s_CommandBuffer.GetNextCommandHandle();
+	CommandHandle_t hCommand = s_CommandBuffer.GetNextCommandHandle();
 
 	// Execute each command immediately
 	const char *pszDataPtr = f;
@@ -684,6 +685,9 @@ void Cmd_Exec_f( const CCommand &args )
 			free( f );
 		}
 	}
+
+	delete[] buf;
+
 	// force any queued convar changes to flush before reading/writing them
 	UpdateMaterialSystemConfig();
 }