This is a revert of https://github.com/GNOME/libxml2/commit/0762c9b69ba01628f72eada1c64ff3d361fb5716 This fixes perl-xml-libxslt test suite https://bugzilla.suse.com/show_bug.cgi?id=1157450 diff --git a/tree.c b/tree.c index 08b1a50..f2b1457 100644 --- a/tree.c +++ b/tree.c @@ -3693,9 +3693,7 @@ xmlNextElementSibling(xmlNodePtr node) { void xmlFreeNodeList(xmlNodePtr cur) { xmlNodePtr next; - xmlNodePtr parent; xmlDictPtr dict = NULL; - size_t depth = 0; if (cur == NULL) return; if (cur->type == XML_NAMESPACE_DECL) { @@ -3703,21 +3701,8 @@ xmlFreeNodeList(xmlNodePtr cur) { return; } if (cur->doc != NULL) dict = cur->doc->dict; - while (1) { - while ((cur->children != NULL) && - (cur->type != XML_DOCUMENT_NODE) && -#ifdef LIBXML_DOCB_ENABLED - (cur->type != XML_DOCB_DOCUMENT_NODE) && -#endif - (cur->type != XML_HTML_DOCUMENT_NODE) && - (cur->type != XML_DTD_NODE) && - (cur->type != XML_ENTITY_REF_NODE)) { - cur = cur->children; - depth += 1; - } - + while (cur != NULL) { next = cur->next; - parent = cur->parent; if ((cur->type == XML_DOCUMENT_NODE) || #ifdef LIBXML_DOCB_ENABLED (cur->type == XML_DOCB_DOCUMENT_NODE) || @@ -3729,6 +3714,9 @@ xmlFreeNodeList(xmlNodePtr cur) { if ((__xmlRegisterCallbacks) && (xmlDeregisterNodeDefaultValue)) xmlDeregisterNodeDefaultValue(cur); + if ((cur->children != NULL) && + (cur->type != XML_ENTITY_REF_NODE)) + xmlFreeNodeList(cur->children); if (((cur->type == XML_ELEMENT_NODE) || (cur->type == XML_XINCLUDE_START) || (cur->type == XML_XINCLUDE_END)) && @@ -3759,16 +3747,7 @@ xmlFreeNodeList(xmlNodePtr cur) { DICT_FREE(cur->name) xmlFree(cur); } - - if (next != NULL) { - cur = next; - } else { - if ((depth == 0) || (parent == NULL)) - break; - depth -= 1; - cur = parent; - cur->children = NULL; - } + cur = next; } }