summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Cedilnik <andy.cedilnik@kitware.com>2004-01-21 18:38:09 (GMT)
committerAndy Cedilnik <andy.cedilnik@kitware.com>2004-01-21 18:38:09 (GMT)
commitd609e037b9a6bb733dd74970994bab62dccecd36 (patch)
treef5bfba7d0ed4cec32b0b6d68b87c6c8d45246297
parent13753b89c208d4d9fd68df4b4f64f7d552f4865e (diff)
downloadCMake-d609e037b9a6bb733dd74970994bab62dccecd36.zip
CMake-d609e037b9a6bb733dd74970994bab62dccecd36.tar.gz
CMake-d609e037b9a6bb733dd74970994bab62dccecd36.tar.bz2
BUG: Fix valgrind error. If working directory is not set do not do chdir
-rw-r--r--Source/kwsys/ProcessUNIX.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c
index 96d1afb..318a99f 100644
--- a/Source/kwsys/ProcessUNIX.c
+++ b/Source/kwsys/ProcessUNIX.c
@@ -1044,20 +1044,21 @@ static int kwsysProcessInitialize(kwsysProcess* cp)
memset(cp->CommandExitCodes, 0, sizeof(int)*cp->NumberOfCommands);
/* Allocate memory to save the real working directory. */
- {
+ if ( cp->WorkingDirectory )
+ {
#if defined(MAXPATHLEN)
- cp->RealWorkingDirectoryLength = MAXPATHLEN;
+ cp->RealWorkingDirectoryLength = MAXPATHLEN;
#elif defined(PATH_MAX)
- cp->RealWorkingDirectoryLength = PATH_MAX;
+ cp->RealWorkingDirectoryLength = PATH_MAX;
#else
- cp->RealWorkingDirectoryLength = 4096;
+ cp->RealWorkingDirectoryLength = 4096;
#endif
- cp->RealWorkingDirectory = malloc(cp->RealWorkingDirectoryLength);
- if(!cp->RealWorkingDirectory)
- {
- return 0;
+ cp->RealWorkingDirectory = malloc(cp->RealWorkingDirectoryLength);
+ if(!cp->RealWorkingDirectory)
+ {
+ return 0;
+ }
}
- }
return 1;
}