mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-01-12 09:17:37 +03:00
Revert "tree: Only allow elements in xmlDocSetRootElement"
This reverts commit 4b698dbaec
.
lxml assumes that xmlDocSetRootElement works with non-elements.
This commit is contained in:
parent
7c5daa3763
commit
5c55332591
@ -224,7 +224,7 @@ extra_post_call = {
|
||||
"xmlAddPrevSibling":
|
||||
"if (ret_val == NULL) { xmlFreeNode(elem) ; elem = NULL ; }",
|
||||
"xmlDocSetRootElement":
|
||||
"if (ret_val == NULL) { xmlFreeNode(root) ; root = NULL ; }",
|
||||
"if (doc == NULL) { xmlFreeNode(root) ; root = NULL ; }",
|
||||
"xmlReplaceNode":
|
||||
"""if (cur != NULL) {
|
||||
xmlUnlinkNode(cur);
|
||||
|
@ -19789,7 +19789,7 @@ test_xmlDocSetRootElement(void) {
|
||||
root = gen_xmlNodePtr_in(n_root, 1);
|
||||
|
||||
ret_val = xmlDocSetRootElement(doc, root);
|
||||
if (ret_val == NULL) { xmlFreeNode(root) ; root = NULL ; }
|
||||
if (doc == NULL) { xmlFreeNode(root) ; root = NULL ; }
|
||||
desret_xmlNodePtr(ret_val);
|
||||
call_tests++;
|
||||
des_xmlDocPtr(n_doc, doc, 0);
|
||||
|
2
tree.c
2
tree.c
@ -5027,7 +5027,7 @@ xmlDocSetRootElement(xmlDocPtr doc, xmlNodePtr root) {
|
||||
xmlNodePtr old = NULL;
|
||||
|
||||
if (doc == NULL) return(NULL);
|
||||
if ((root == NULL) || (root->type != XML_ELEMENT_NODE))
|
||||
if ((root == NULL) || (root->type == XML_NAMESPACE_DECL))
|
||||
return(NULL);
|
||||
old = doc->children;
|
||||
while (old != NULL) {
|
||||
|
Loading…
Reference in New Issue
Block a user