From 2beb521c812e103ec23126db5828193fa239d2bd Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 13 Jan 2014 15:41:09 +0100 Subject: [PATCH] Router: use shared_ptr rather than naked one To avoid leak if an exception is thrown in configure. --- src/router_flexml.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/router_flexml.cpp b/src/router_flexml.cpp index ba1afa0..6e246d9 100644 --- a/src/router_flexml.cpp +++ b/src/router_flexml.cpp @@ -130,15 +130,14 @@ void mp::RouterFleXML::Rep::parse_xml_filters(xmlDocPtr doc, type_value.c_str(), m_dl_path.c_str()); m_factory->add_creator_dl(type_value, m_dl_path); } - mp::filter::Base* filter_base = m_factory->create(type_value); + boost::shared_ptr fb(m_factory->create(type_value)); - filter_base->configure(node, test_only, file_include_path); + fb->configure(node, test_only, file_include_path); if (m_id_filter_map.find(id_value) != m_id_filter_map.end()) throw mp::XMLError("Filter " + id_value + " already defined"); - m_id_filter_map[id_value] = - boost::shared_ptr(filter_base); + m_id_filter_map[id_value] = fb; node = mp::xml::jump_to_next(node, XML_ELEMENT_NODE); } -- 1.7.10.4