BUG: Fix valgrind error. If working directory is not set do not do chdir
This commit is contained in:
parent
13753b89c2
commit
d609e037b9
|
@ -1044,20 +1044,21 @@ static int kwsysProcessInitialize(kwsysProcess* cp)
|
||||||
memset(cp->CommandExitCodes, 0, sizeof(int)*cp->NumberOfCommands);
|
memset(cp->CommandExitCodes, 0, sizeof(int)*cp->NumberOfCommands);
|
||||||
|
|
||||||
/* Allocate memory to save the real working directory. */
|
/* Allocate memory to save the real working directory. */
|
||||||
{
|
if ( cp->WorkingDirectory )
|
||||||
#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;
|
#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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue