summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2001-03-15 15:42:43 (GMT)
committerBrad King <brad.king@kitware.com>2001-03-15 15:42:43 (GMT)
commit354992c522048c8e1bfd3b786841e7be4ca2ef9f (patch)
treeeff025b52df23c76b2cb4eb3ff3140e8b2f76edf /Source
parentd3735b65d607d6a999f8dc99ff7e0a3b6b18694e (diff)
downloadCMake-354992c522048c8e1bfd3b786841e7be4ca2ef9f.zip
CMake-354992c522048c8e1bfd3b786841e7be4ca2ef9f.tar.gz
CMake-354992c522048c8e1bfd3b786841e7be4ca2ef9f.tar.bz2
BUG: Fixed segfault when CABLE_PACKAGE is only CABLE command. Related to order of virtual destructor calls.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmCablePackageCommand.cxx19
-rw-r--r--Source/cmCablePackageCommand.h2
2 files changed, 19 insertions, 2 deletions
diff --git a/Source/cmCablePackageCommand.cxx b/Source/cmCablePackageCommand.cxx
index 73f8f18..4c334a7 100644
--- a/Source/cmCablePackageCommand.cxx
+++ b/Source/cmCablePackageCommand.cxx
@@ -16,6 +16,23 @@
#include "cmCablePackageCommand.h"
#include "cmCacheManager.h"
+
+cmCablePackageCommand::~cmCablePackageCommand()
+{
+ // If we are the owner of the cmCableData, we must delete it here.
+ // For most cmCableCommands, the cmCableCommand destructor will take
+ // care of this. If this package happens to be the last one, and is
+ // the owner, then the destructor of cmCableData will call back to a method
+ // in this class after the package part of it has been freed!
+ if(m_CableData && m_CableData->OwnerIs(this))
+ {
+ delete m_CableData;
+ // Make sure our superclass's destructor doesn't try to delete the
+ // cmCableData too.
+ m_CableData = NULL;
+ }
+}
+
// cmCablePackageCommand
bool cmCablePackageCommand::Invoke(std::vector<std::string>& args)
{
@@ -30,7 +47,7 @@ bool cmCablePackageCommand::Invoke(std::vector<std::string>& args)
// The argument is the package name.
m_PackageName = args[0];
-
+
// Ask the cable data to begin the package. This may call another
// cmCablePackageCommand's WritePackageFooter(). This will call
// this cmCablePackageCommand's WritePackageHeader().
diff --git a/Source/cmCablePackageCommand.h b/Source/cmCablePackageCommand.h
index b8a76c7..e240ea1 100644
--- a/Source/cmCablePackageCommand.h
+++ b/Source/cmCablePackageCommand.h
@@ -30,7 +30,7 @@ class cmCablePackageCommand : public cmCableCommand
{
public:
cmCablePackageCommand() {}
- virtual ~cmCablePackageCommand() {}
+ virtual ~cmCablePackageCommand();
/**
* This is a virtual constructor for the command.