summaryrefslogtreecommitdiffstats
path: root/Source/cmTarget.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-07-06 20:24:32 (GMT)
committerBrad King <brad.king@kitware.com>2009-07-06 20:24:32 (GMT)
commit82a8c6b0c725496315e45e11ce8bcfb970c82bcf (patch)
tree9baa68401cd24f44a2e52ca40b8322ba551d8897 /Source/cmTarget.cxx
parent2b85fcdd7d6fb3f08a20d57f3c6bdad30d9d880c (diff)
downloadCMake-82a8c6b0c725496315e45e11ce8bcfb970c82bcf.zip
CMake-82a8c6b0c725496315e45e11ce8bcfb970c82bcf.tar.gz
CMake-82a8c6b0c725496315e45e11ce8bcfb970c82bcf.tar.bz2
ENH: Exception safe link interface computation
This fixes cmTarget::GetLinkInterface to compute and return the link interface in an exception-safe manner. We manage the link interface returned by cmTarget::ComputeLinkInterface using auto_ptr.
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r--Source/cmTarget.cxx17
1 files changed, 10 insertions, 7 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 6065890..3d6e1b7 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -3696,19 +3696,22 @@ cmTargetLinkInterface const* cmTarget::GetLinkInterface(const char* config)
if(i == this->LinkInterface.end())
{
// Compute the link interface for this configuration.
- cmTargetLinkInterface* iface = this->ComputeLinkInterface(config);
+ cmsys::auto_ptr<cmTargetLinkInterface>
+ iface(this->ComputeLinkInterface(config));
// Store the information for this configuration.
std::map<cmStdString, cmTargetLinkInterface*>::value_type
- entry(config?config:"", iface);
+ entry(config?config:"", 0);
i = this->LinkInterface.insert(entry).first;
+ i->second = iface.release();
}
return i->second;
}
//----------------------------------------------------------------------------
-cmTargetLinkInterface* cmTarget::ComputeLinkInterface(const char* config)
+cmsys::auto_ptr<cmTargetLinkInterface>
+cmTarget::ComputeLinkInterface(const char* config)
{
// Construct the property name suffix for this configuration.
std::string suffix = "_";
@@ -3739,14 +3742,14 @@ cmTargetLinkInterface* cmTarget::ComputeLinkInterface(const char* config)
// If still not set, there is no link interface.
if(!libs)
{
- return 0;
+ return cmsys::auto_ptr<cmTargetLinkInterface>();
}
// Allocate the interface.
- cmTargetLinkInterface* iface = new cmTargetLinkInterface;
- if(!iface)
+ cmsys::auto_ptr<cmTargetLinkInterface> iface(new cmTargetLinkInterface);
+ if(!iface.get())
{
- return 0;
+ return cmsys::auto_ptr<cmTargetLinkInterface>();
}
// Expand the list of libraries in the interface.