From d350fb688954f476d8df79bf582cf366b5861dd2 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 19 Apr 2019 13:31:52 -0400 Subject: execute_process: Manage KWSys Process lifetime with unique_ptr --- Source/cmExecuteProcessCommand.cxx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx index ff6340f..de58c0b 100644 --- a/Source/cmExecuteProcessCommand.cxx +++ b/Source/cmExecuteProcessCommand.cxx @@ -119,7 +119,9 @@ bool cmExecuteProcessCommand::InitialPass(std::vector const& args, } // Create a process instance. - cmsysProcess* cp = cmsysProcess_New(); + std::unique_ptr cp_ptr( + cmsysProcess_New(), cmsysProcess_Delete); + cmsysProcess* cp = cp_ptr.get(); // Set the command sequence. for (std::vector const& cmd : arguments.Commands) { @@ -297,9 +299,6 @@ bool cmExecuteProcessCommand::InitialPass(std::vector const& args, } } - // Delete the process instance. - cmsysProcess_Delete(cp); - return true; } -- cgit v0.12