mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-24 13:33:01 +03:00
tree: Only allow elements in xmlDocSetRootElement
This commit is contained in:
@@ -224,7 +224,7 @@ extra_post_call = {
|
|||||||
"xmlAddPrevSibling":
|
"xmlAddPrevSibling":
|
||||||
"if (ret_val == NULL) { xmlFreeNode(elem) ; elem = NULL ; }",
|
"if (ret_val == NULL) { xmlFreeNode(elem) ; elem = NULL ; }",
|
||||||
"xmlDocSetRootElement":
|
"xmlDocSetRootElement":
|
||||||
"if (doc == NULL) { xmlFreeNode(root) ; root = NULL ; }",
|
"if (ret_val == NULL) { xmlFreeNode(root) ; root = NULL ; }",
|
||||||
"xmlReplaceNode":
|
"xmlReplaceNode":
|
||||||
"""if (cur != NULL) {
|
"""if (cur != NULL) {
|
||||||
xmlUnlinkNode(cur);
|
xmlUnlinkNode(cur);
|
||||||
|
|||||||
@@ -19789,7 +19789,7 @@ test_xmlDocSetRootElement(void) {
|
|||||||
root = gen_xmlNodePtr_in(n_root, 1);
|
root = gen_xmlNodePtr_in(n_root, 1);
|
||||||
|
|
||||||
ret_val = xmlDocSetRootElement(doc, root);
|
ret_val = xmlDocSetRootElement(doc, root);
|
||||||
if (doc == NULL) { xmlFreeNode(root) ; root = NULL ; }
|
if (ret_val == NULL) { xmlFreeNode(root) ; root = NULL ; }
|
||||||
desret_xmlNodePtr(ret_val);
|
desret_xmlNodePtr(ret_val);
|
||||||
call_tests++;
|
call_tests++;
|
||||||
des_xmlDocPtr(n_doc, doc, 0);
|
des_xmlDocPtr(n_doc, doc, 0);
|
||||||
|
|||||||
2
tree.c
2
tree.c
@@ -5060,7 +5060,7 @@ xmlDocSetRootElement(xmlDocPtr doc, xmlNodePtr root) {
|
|||||||
xmlNodePtr old = NULL;
|
xmlNodePtr old = NULL;
|
||||||
|
|
||||||
if (doc == NULL) return(NULL);
|
if (doc == NULL) return(NULL);
|
||||||
if ((root == NULL) || (root->type == XML_NAMESPACE_DECL))
|
if ((root == NULL) || (root->type != XML_ELEMENT_NODE))
|
||||||
return(NULL);
|
return(NULL);
|
||||||
xmlUnlinkNode(root);
|
xmlUnlinkNode(root);
|
||||||
xmlSetTreeDoc(root, doc);
|
xmlSetTreeDoc(root, doc);
|
||||||
|
|||||||
Reference in New Issue
Block a user