summaryrefslogtreecommitdiffstats
path: root/Source/cmCustomCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-07-17 15:02:46 (GMT)
committerBrad King <brad.king@kitware.com>2013-07-17 15:18:06 (GMT)
commit17c841c42d69987c84940232428928c39f1637cd (patch)
treeb8ddfe75ef963e2910f6cdf89409f195fa0a694f /Source/cmCustomCommand.cxx
parent5dd8c01429da90a7417b72f17e784cc98f70f57c (diff)
downloadCMake-17c841c42d69987c84940232428928c39f1637cd.zip
CMake-17c841c42d69987c84940232428928c39f1637cd.tar.gz
CMake-17c841c42d69987c84940232428928c39f1637cd.tar.bz2
add_custom_command: Manage backtrace memory correctly (#14299)
Add an assignment operator to cmCustomCommand to copy the Backtrace member pointee and avoid multiple-free on destruction. Reported-by: Vitezslav Cizek <vcizek@suse.cz>
Diffstat (limited to 'Source/cmCustomCommand.cxx')
-rw-r--r--Source/cmCustomCommand.cxx28
1 files changed, 28 insertions, 0 deletions
diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx
index bd860ee..3620a38 100644
--- a/Source/cmCustomCommand.cxx
+++ b/Source/cmCustomCommand.cxx
@@ -13,6 +13,8 @@
#include "cmMakefile.h"
+#include <cmsys/auto_ptr.hxx>
+
//----------------------------------------------------------------------------
cmCustomCommand::cmCustomCommand()
{
@@ -36,6 +38,32 @@ cmCustomCommand::cmCustomCommand(const cmCustomCommand& r):
}
//----------------------------------------------------------------------------
+cmCustomCommand& cmCustomCommand::operator=(cmCustomCommand const& r)
+{
+ if(this == &r)
+ {
+ return *this;
+ }
+
+ this->Outputs = r.Outputs;
+ this->Depends = r.Depends;
+ this->CommandLines = r.CommandLines;
+ this->HaveComment = r.HaveComment;
+ this->Comment = r.Comment;
+ this->WorkingDirectory = r.WorkingDirectory;
+ this->EscapeAllowMakeVars = r.EscapeAllowMakeVars;
+ this->EscapeOldStyle = r.EscapeOldStyle;
+ this->ImplicitDepends = r.ImplicitDepends;
+
+ cmsys::auto_ptr<cmListFileBacktrace>
+ newBacktrace(new cmListFileBacktrace(*r.Backtrace));
+ delete this->Backtrace;
+ this->Backtrace = newBacktrace.release();
+
+ return *this;
+}
+
+//----------------------------------------------------------------------------
cmCustomCommand::cmCustomCommand(cmMakefile* mf,
const std::vector<std::string>& outputs,
const std::vector<std::string>& depends,