aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2005-05-25 19:20:59 +0000
committerVincent Richard <[email protected]>2005-05-25 19:20:59 +0000
commitb3ddee2ea73d518bffa5a5c1d982ed09d0ddd57e (patch)
treee873dff21cf04c5a61f786c58a0498281e3db929
parentRemoved redundant field name. (diff)
downloadvmime-b3ddee2ea73d518bffa5a5c1d982ed09d0ddd57e.tar.gz
vmime-b3ddee2ea73d518bffa5a5c1d982ed09d0ddd57e.zip
Free memory for args.
-rw-r--r--src/platforms/posix/posixChildProcess.cpp11
-rw-r--r--vmime/platforms/posix/posixChildProcess.hpp3
2 files changed, 11 insertions, 3 deletions
diff --git a/src/platforms/posix/posixChildProcess.cpp b/src/platforms/posix/posixChildProcess.cpp
index c44e1549..54410bf6 100644
--- a/src/platforms/posix/posixChildProcess.cpp
+++ b/src/platforms/posix/posixChildProcess.cpp
@@ -200,7 +200,7 @@ private:
posixChildProcess::posixChildProcess(const utility::file::path& path)
: m_processPath(path), m_started(false),
- m_stdIn(NULL), m_stdOut(NULL), m_pid(0)
+ m_stdIn(NULL), m_stdOut(NULL), m_pid(0), m_argArray(NULL)
{
m_pipe[0] = 0;
m_pipe[1] = 0;
@@ -222,6 +222,8 @@ posixChildProcess::~posixChildProcess()
delete (m_stdIn);
delete (m_stdOut);
+
+ delete [] (m_argArray);
}
@@ -239,11 +241,14 @@ void posixChildProcess::start(const std::vector <string> args, const int flags)
// Construct C-style argument array
const char** argv = new const char*[args.size() + 2];
+ m_argVector = args; // for c_str() pointer to remain valid
+ m_argArray = argv; // to free later
+
argv[0] = m_processPath.getLastComponent().getBuffer().c_str();
argv[args.size()] = NULL;
- for (unsigned int i = 0 ; i < args.size() ; ++i)
- argv[i + 1] = args[i].c_str();
+ for (unsigned int i = 0 ; i < m_argVector.size() ; ++i)
+ argv[i + 1] = m_argVector[i].c_str();
// Create a pipe to communicate with the child process
int fd[2];
diff --git a/vmime/platforms/posix/posixChildProcess.hpp b/vmime/platforms/posix/posixChildProcess.hpp
index 96d50d5a..0fa15406 100644
--- a/vmime/platforms/posix/posixChildProcess.hpp
+++ b/vmime/platforms/posix/posixChildProcess.hpp
@@ -54,6 +54,9 @@ private:
sigset_t m_oldProcMask;
pid_t m_pid;
int m_pipe[2];
+
+ std::vector <string> m_argVector;
+ const char** m_argArray;
};