]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Fix constructor fiddle in last change.
authorRoland McGrath <roland@redhat.com>
Sat, 4 Jul 2009 02:59:40 +0000 (19:59 -0700)
committerRoland McGrath <roland@redhat.com>
Sat, 4 Jul 2009 02:59:40 +0000 (19:59 -0700)
libdw/c++/dwarf_edit

index 6b94382999bf5b6087c5f82b08df335cd1da5c1d..92645a36657f3d1062252e78fa43db4f1c7e2e74 100644 (file)
@@ -175,13 +175,20 @@ namespace elfutils
       template<typename die_type, typename arg_type>
       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<compile_unit>
     {
       friend class dwarf_edit;
+
     private:
       typedef std::list<compile_unit> _base;