From 2876af6773881158ae82b7031e3af9b95e243c14 Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine@gmail.com" Date: Sat, 29 Sep 2012 06:36:29 +0000 Subject: Fix find_child_by_attribute assertion for attributes with null name/value. git-svn-id: http://pugixml.googlecode.com/svn/trunk@920 99668b35-9821-0410-8761-19e4c4f06640 --- src/pugixml.cpp | 4 ++-- tests/test_dom_traverse.cpp | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 4035ab1..03a4b9f 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -4507,7 +4507,7 @@ namespace pugi if (i->name && impl::strequal(name_, i->name)) { for (xml_attribute_struct* a = i->first_attribute; a; a = a->next_attribute) - if (impl::strequal(attr_name, a->name) && impl::strequal(attr_value, a->value)) + if (a->name && impl::strequal(attr_name, a->name) && impl::strequal(attr_value, a->value ? a->value : PUGIXML_TEXT(""))) return xml_node(i); } @@ -4520,7 +4520,7 @@ namespace pugi for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling) for (xml_attribute_struct* a = i->first_attribute; a; a = a->next_attribute) - if (impl::strequal(attr_name, a->name) && impl::strequal(attr_value, a->value)) + if (a->name && impl::strequal(attr_name, a->name) && impl::strequal(attr_value, a->value ? a->value : PUGIXML_TEXT(""))) return xml_node(i); return xml_node(); diff --git a/tests/test_dom_traverse.cpp b/tests/test_dom_traverse.cpp index 738b53d..1af8572 100644 --- a/tests/test_dom_traverse.cpp +++ b/tests/test_dom_traverse.cpp @@ -537,6 +537,31 @@ TEST_XML(dom_node_find_child_by_attribute, "