diff --git a/lib/icinga/service-comment.cpp b/lib/icinga/service-comment.cpp index 7a9ae1330..f16faa4ad 100644 --- a/lib/icinga/service-comment.cpp +++ b/lib/icinga/service-comment.cpp @@ -88,9 +88,11 @@ void Service::RemoveAllComments(void) std::vector ids; Dictionary::Ptr comments = GetComments(); - ObjectLock olock(comments); - BOOST_FOREACH(const Dictionary::Pair& kv, comments) { - ids.push_back(kv.first); + { + ObjectLock olock(comments); + BOOST_FOREACH(const Dictionary::Pair& kv, comments) { + ids.push_back(kv.first); + } } BOOST_FOREACH(const String& id, ids) {