From e87e2011f5807122991352ce1f7e155e954a47a4 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Wed, 23 Jan 2019 10:37:42 +0100 Subject: [PATCH] Remove some leaks --- src/Launcher/Launcher.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Launcher/Launcher.cxx b/src/Launcher/Launcher.cxx index 1adc894f2..1226253fe 100644 --- a/src/Launcher/Launcher.cxx +++ b/src/Launcher/Launcher.cxx @@ -378,7 +378,8 @@ Launcher_cpp::createJobWithFile(const std::string xmlExecuteFile, ParserLauncherType job_params = ParseXmlFile(xmlExecuteFile); // Creating a new job - Launcher::Job_Command * new_job = new Launcher::Job_Command(); + auto JobDel = [] (Launcher::Job *job) { if(job) job->decrRef(); }; + std::unique_ptr new_job(new Launcher::Job_Command,JobDel); std::string cmdFile = Kernel_Utils::GetTmpFileName(); #ifndef WIN32 @@ -413,7 +414,7 @@ Launcher_cpp::createJobWithFile(const std::string xmlExecuteFile, p.mem_mb = 0; new_job->setResourceRequiredParams(p); - createJob(new_job); + createJob(new_job.get()); return new_job->getNumber(); } @@ -535,7 +536,6 @@ void Launcher_cpp::createJob(Launcher::Job * new_job) { LAUNCHER_INFOS("Launcher compiled without LIBBATCH - cannot create a job !!!"); - delete new_job; throw LauncherException("Method Launcher_cpp::createJob is not available " "(libBatch was not present at compilation time)"); } -- 2.39.2