[icinga-checkins] icinga.org: icinga2/master: Bugfix: Crash while reloading config

git at icinga.org git at icinga.org
Sun Feb 3 16:02:37 CET 2013


Module: icinga2
Branch: master
Commit: b997462eef36fd735c64271ca5f5b146fcde1aa3
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=b997462eef36fd735c64271ca5f5b146fcde1aa3

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Sun Feb  3 15:47:11 2013 +0100

Bugfix: Crash while reloading config

Fixes #3621

---

 lib/config/configitem.cpp |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/lib/config/configitem.cpp b/lib/config/configitem.cpp
index 27f3ee0..dd52515 100644
--- a/lib/config/configitem.cpp
+++ b/lib/config/configitem.cpp
@@ -188,8 +188,12 @@ DynamicObject::Ptr ConfigItem::Commit(void)
 		parent->RegisterChild(GetSelf());
 	}
 
+	/* We need to make a copy of the child objects becauuse the
+	 * OnParentCommitted() handler is going to update the list. */
+	set<ConfigItem::WeakPtr> children = m_ChildObjects;
+
 	/* notify our children of the update */
-	BOOST_FOREACH(const ConfigItem::WeakPtr wchild, m_ChildObjects) {
+	BOOST_FOREACH(const ConfigItem::WeakPtr wchild, children) {
 		const ConfigItem::Ptr& child = wchild.lock();
 
 		if (!child)
@@ -240,7 +244,9 @@ void ConfigItem::UnregisterFromParents(void)
 {
 	BOOST_FOREACH(const String& parentName, m_Parents) {
 		ConfigItem::Ptr parent = GetObject(GetType(), parentName);
-		parent->UnregisterChild(GetSelf());
+
+		if (parent)
+			parent->UnregisterChild(GetSelf());
 	}
 }
 
@@ -302,4 +308,4 @@ void ConfigItem::Dump(ostream& fp) const
 	fp << " {" << "\n";
 	m_ExpressionList->Dump(fp, 1);
 	fp << "}" << "\n";
-}
\ No newline at end of file
+}





More information about the icinga-checkins mailing list