summaryrefslogtreecommitdiff
path: root/Source/cmVariableWatch.cxx
diff options
context:
space:
mode:
authorBen Boeckel <mathstuf@gmail.com>2013-08-02 15:49:28 -0400
committerBrad King <brad.king@kitware.com>2013-08-08 13:31:09 -0400
commit00ce12a3347d1fef25badff00c5abc3dc715f207 (patch)
tree9033b85c5ab80cb9c272a02bdf8bb1c8476512b3 /Source/cmVariableWatch.cxx
parent34b397e8dec04c55b415ee0e5f9172f624156d36 (diff)
downloadcmake-00ce12a3347d1fef25badff00c5abc3dc715f207.tar.gz
variable_watch: Prevent making extra entries in the watch map
When removing a watch on a variable, using the operator [] on the internal map will create an empty watch if the variable doesn't have any existing watches. Rather than creating this empty structure in the map, return if there isn't a watch on the variable already.
Diffstat (limited to 'Source/cmVariableWatch.cxx')
-rw-r--r--Source/cmVariableWatch.cxx4
1 files changed, 4 insertions, 0 deletions
diff --git a/Source/cmVariableWatch.cxx b/Source/cmVariableWatch.cxx
index d049cddeac..8ad6fce8f3 100644
--- a/Source/cmVariableWatch.cxx
+++ b/Source/cmVariableWatch.cxx
@@ -80,6 +80,10 @@ void cmVariableWatch::RemoveWatch(const std::string& variable,
WatchMethod method,
void* client_data /*=0*/)
{
+ if ( !this->WatchMap.count(variable) )
+ {
+ return;
+ }
cmVariableWatch::VectorOfPairs* vp = &this->WatchMap[variable];
cmVariableWatch::VectorOfPairs::iterator it;
for ( it = vp->begin(); it != vp->end(); ++it )