From 76b4a7ad18db196441ee7ce976b61b2ad42a0e75 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Fri, 3 Jul 2009 19:59:40 -0700 Subject: [PATCH] Fix constructor fiddle in last change. --- libdw/c++/dwarf_edit | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/libdw/c++/dwarf_edit b/libdw/c++/dwarf_edit index 6b9438299..92645a366 100644 --- a/libdw/c++/dwarf_edit +++ b/libdw/c++/dwarf_edit @@ -175,13 +175,20 @@ namespace elfutils template inline void set (const die_type &die, arg_type &arg) { - /* Clear the old containers first so in exceptions we can't leave - the tag changed but the old containers intact. */ - _m_attributes.clear (); - _m_children.clear (); - _m_tag = die.tag (); - _m_attributes = std::move (attributes_type (die.attributes (), arg)); - _m_children = std::move (children_type (die.children (), arg)); + try + { + _m_tag = die.tag (); + _m_attributes.swap (attributes_type (die.attributes (), arg)); + _m_children.swap (children_type (die.children (), arg)); + } + catch (...) + { + // Never leave a partially-formed DIE. + _m_tag = -1; + _m_attributes.clear (); + _m_children.clear (); + throw; + }; } public: @@ -287,6 +294,7 @@ namespace elfutils class compile_units : public std::list { friend class dwarf_edit; + private: typedef std::list _base; -- 2.47.2