From cf8beae38fc40d6e4ae43e0055116a03fe7838f2 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer <eike@sf-mail.de> Date: Sat, 7 Oct 2017 23:14:48 +0200 Subject: [PATCH] ProcessUNIX: use strdup() instead of open coding it --- ProcessUNIX.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ProcessUNIX.c b/ProcessUNIX.c index 3b32ca7..80c053c 100644 --- a/ProcessUNIX.c +++ b/ProcessUNIX.c @@ -498,11 +498,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; } @@ -531,11 +530,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 -- GitLab