From 62ea802cea096401af95ac52ad0a2c1c20d4954b Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 15 Sep 2009 06:12:42 +0000 Subject: [PATCH] Quote commandline args with spaces when building the string for Com_Init(). --- code/sys/sys_main.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/code/sys/sys_main.c b/code/sys/sys_main.c index eb49326d..ff581871 100644 --- a/code/sys/sys_main.c +++ b/code/sys/sys_main.c @@ -542,7 +542,15 @@ int main( int argc, char **argv ) // Concatenate the command line for passing to Com_Init for( i = 1; i < argc; i++ ) { + const qboolean containsSpaces = strchr(argv[i], ' ') != NULL; + if (containsSpaces) + Q_strcat( commandLine, sizeof( commandLine ), "\"" ); + Q_strcat( commandLine, sizeof( commandLine ), argv[ i ] ); + + if (containsSpaces) + Q_strcat( commandLine, sizeof( commandLine ), "\"" ); + Q_strcat( commandLine, sizeof( commandLine ), " " ); }