summaryrefslogtreecommitdiff
path: root/src/pugixml.cpp
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2014-08-11 00:13:47 +0000
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2014-08-11 00:13:47 +0000
commitb5556f184f3ea6f0c88820a486a843c471d612cc (patch)
tree394b1e7c865a9d458ae7abc917eae8b71ba7e087 /src/pugixml.cpp
parenteb3ca4e154d740ef5bdfdbcff80a1cb9ced80425 (diff)
Move attribute name setup after pointer setup to handle exceptions better
git-svn-id: https://pugixml.googlecode.com/svn/trunk@1005 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'src/pugixml.cpp')
-rw-r--r--src/pugixml.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp
index cc19c8a..b4255bd 100644
--- a/src/pugixml.cpp
+++ b/src/pugixml.cpp
@@ -4593,6 +4593,7 @@ namespace pugi
if (type() != node_element && type() != node_declaration) return xml_attribute();
xml_attribute a(impl::append_new_attribute(_root, impl::get_allocator(_root)));
+
a.set_name(name_);
return a;
@@ -4605,8 +4606,6 @@ namespace pugi
xml_attribute a(impl::allocate_attribute(impl::get_allocator(_root)));
if (!a) return xml_attribute();
- a.set_name(name_);
-
xml_attribute_struct* head = _root->first_attribute;
if (head)
@@ -4619,7 +4618,9 @@ namespace pugi
a._attr->next_attribute = head;
_root->first_attribute = a._attr;
-
+
+ a.set_name(name_);
+
return a;
}
@@ -4637,8 +4638,6 @@ namespace pugi
xml_attribute a(impl::allocate_attribute(impl::get_allocator(_root)));
if (!a) return xml_attribute();
- a.set_name(name_);
-
if (attr._attr->prev_attribute_c->next_attribute)
attr._attr->prev_attribute_c->next_attribute = a._attr;
else
@@ -4648,6 +4647,8 @@ namespace pugi
a._attr->next_attribute = attr._attr;
attr._attr->prev_attribute_c = a._attr;
+ a.set_name(name_);
+
return a;
}
@@ -4665,8 +4666,6 @@ namespace pugi
xml_attribute a(impl::allocate_attribute(impl::get_allocator(_root)));
if (!a) return xml_attribute();
- a.set_name(name_);
-
if (attr._attr->next_attribute)
attr._attr->next_attribute->prev_attribute_c = a._attr;
else
@@ -4676,6 +4675,8 @@ namespace pugi
a._attr->prev_attribute_c = attr._attr;
attr._attr->next_attribute = a._attr;
+ a.set_name(name_);
+
return a;
}