diff --git a/ProcessUNIX.c b/ProcessUNIX.c index be28b268bbd71dce13161de270d1d05463d12930..1431f30f9a42fbe9e3a17e7959358d1347ba8cc2 100644 --- a/ProcessUNIX.c +++ b/ProcessUNIX.c @@ -496,11 +496,10 @@ int kwsysProcess_SetWorkingDirectory(kwsysProcess* cp, const char* dir) cp->WorkingDirectory = 0; } if (dir) { - cp->WorkingDirectory = (char*)malloc(strlen(dir) + 1); + cp->WorkingDirectory = strdup(dir); if (!cp->WorkingDirectory) { return 0; } - strcpy(cp->WorkingDirectory, dir); } return 1; } @@ -529,11 +528,10 @@ int kwsysProcess_SetPipeFile(kwsysProcess* cp, int prPipe, const char* file) *pfile = 0; } if (file) { - *pfile = (char*)malloc(strlen(file) + 1); + *pfile = strdup(file); if (!*pfile) { return 0; } - strcpy(*pfile, file); } /* If we are redirecting the pipe, do not share it or use a native diff --git a/ProcessWin32.c b/ProcessWin32.c index ff95dc64c093d77f0f10228067bf59c03327a920..945fa28427c2995ce2485ec5217d0e5ae60cbec2 100644 --- a/ProcessWin32.c +++ b/ProcessWin32.c @@ -711,11 +711,10 @@ int kwsysProcess_SetPipeFile(kwsysProcess* cp, int pipe, const char* file) *pfile = 0; } if (file) { - *pfile = (char*)malloc(strlen(file) + 1); + *pfile = strdup(file); if (!*pfile) { return 0; } - strcpy(*pfile, file); } /* If we are redirecting the pipe, do not share it or use a native