Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.executable/library/win32/eclipseWin.c')
-rw-r--r--bundles/org.eclipse.equinox.executable/library/win32/eclipseWin.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/bundles/org.eclipse.equinox.executable/library/win32/eclipseWin.c b/bundles/org.eclipse.equinox.executable/library/win32/eclipseWin.c
index 7edada558..52b36b503 100644
--- a/bundles/org.eclipse.equinox.executable/library/win32/eclipseWin.c
+++ b/bundles/org.eclipse.equinox.executable/library/win32/eclipseWin.c
@@ -312,7 +312,7 @@ static _TCHAR* checkVMRegistryKey(HKEY jreKey, _TCHAR* subKeyName) {
static _TCHAR* buildCommandLine( _TCHAR* program, _TCHAR* args[] )
{
- int index;
+ int index, slash;
size_t length = 0;
_TCHAR *commandLine, *ch, *space;
@@ -326,8 +326,8 @@ static _TCHAR* buildCommandLine( _TCHAR* program, _TCHAR* args[] )
{
/* String length plus space character */
length += _tcslen( args[ index ] ) + 1;
- /* Quotes */
- if (_tcschr( args[ index ], _T(' ') ) != NULL) length += 2;
+ /* Quotes + potential escaping '\' */
+ if (_tcschr( args[ index ], _T(' ') ) != NULL) length += 3;
}
commandLine = ch = malloc ( (length + 1) * sizeof(_TCHAR) );
@@ -342,7 +342,15 @@ static _TCHAR* buildCommandLine( _TCHAR* program, _TCHAR* args[] )
if (space != NULL) *ch++ = _T('\"');
_tcscpy( ch, args[index] );
ch += _tcslen( args[index] );
- if (space != NULL) *ch++ = _T('\"');
+ if (space != NULL) {
+ if ( *(ch - 1) == _T('\\') ) {
+ /* escape a trailing unescaped '\' or it will escape our closing '"' and mess things up */
+ slash = 1;
+ while ( *(ch - 1 - slash) == _T('\\')) slash++;
+ if (slash % 2) *ch++ = _T('\\');
+ }
+ *ch++ = _T('\"');
+ }
*ch++ = _T(' ');
}
*ch = _T('\0');

Back to the top