From 754f0397d2cca565f498dc15328e32743c11f22b Mon Sep 17 00:00:00 2001 From: Lyubomir Marinov Date: Thu, 2 Jun 2011 17:08:41 +0000 Subject: [PATCH] Fixes a memory corruption causing a run.exe crash which has been reported multiple times on the dev and users mailing lists. --- src/native/windows/run/run.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/native/windows/run/run.c b/src/native/windows/run/run.c index 63b8c3d8d..01441057a 100644 --- a/src/native/windows/run/run.c +++ b/src/native/windows/run/run.c @@ -318,7 +318,14 @@ Run_getJavaExeCommandLine(LPCTSTR javaExe, LPTSTR *commandLine) + 2); } mainClassLength = _tcslen(mainClass); - cmdLineLength = Run_cmdLine ? (1 /* ' ' */ + _tcslen(Run_cmdLine)) : 0; + if (Run_cmdLine) + { + cmdLineLength = _tcslen(Run_cmdLine); + if (cmdLineLength) + cmdLineLength++; /* ' ' */ + } + else + cmdLineLength = 0; *commandLine = (LPTSTR) @@ -412,10 +419,11 @@ Run_getJavaExeCommandLine(LPCTSTR javaExe, LPTSTR *commandLine) } _tcsncpy(str, mainClass, mainClassLength); str += mainClassLength; - if (Run_cmdLine) + if (cmdLineLength) { *str = _T(' '); str++; + cmdLineLength--; _tcsncpy(str, Run_cmdLine, cmdLineLength); str += cmdLineLength; } @@ -451,9 +459,9 @@ Run_getJavaLibraryPath() { LPTSTR str = javaLibraryPath; - *str = _T('"'); + *str = _T('\"'); str += (1 + javaLibraryPathLength); - *str = _T('"'); + *str = _T('\"'); str++; *str = 0;