From 00ce12a3347d1fef25badff00c5abc3dc715f207 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 2 Aug 2013 15:49:28 -0400 Subject: 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. --- Source/cmVariableWatch.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/cmVariableWatch.cxx b/Source/cmVariableWatch.cxx index d049cdd..8ad6fce 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 ) -- cgit v0.12