From: Adam Dickmeiss Date: Mon, 13 Jan 2014 14:41:09 +0000 (+0100) Subject: Router: use shared_ptr rather than naked one X-Git-Tag: v1.4.4~7 X-Git-Url: http://lists.indexdata.com/cgi-bin?a=commitdiff_plain;h=2beb521c812e103ec23126db5828193fa239d2bd;p=metaproxy-moved-to-github.git Router: use shared_ptr rather than naked one To avoid leak if an exception is thrown in configure. --- 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); }