BUG: Fix valgrind error. If working directory is not set do not do chdir

This commit is contained in:
Andy Cedilnik 2004-01-21 13:38:09 -05:00
parent 13753b89c2
commit d609e037b9
1 changed files with 13 additions and 12 deletions

View File

@ -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 defined(MAXPATHLEN)
cp->RealWorkingDirectoryLength = MAXPATHLEN;
#elif defined(PATH_MAX)
cp->RealWorkingDirectoryLength = PATH_MAX;
#else
cp->RealWorkingDirectoryLength = 4096;
#endif
cp->RealWorkingDirectory = malloc(cp->RealWorkingDirectoryLength);
if(!cp->RealWorkingDirectory)
if ( cp->WorkingDirectory )
{
return 0;
#if defined(MAXPATHLEN)
cp->RealWorkingDirectoryLength = MAXPATHLEN;
#elif defined(PATH_MAX)
cp->RealWorkingDirectoryLength = PATH_MAX;
#else
cp->RealWorkingDirectoryLength = 4096;
#endif
cp->RealWorkingDirectory = malloc(cp->RealWorkingDirectoryLength);
if(!cp->RealWorkingDirectory)
{
return 0;
}
}
}
return 1;
}