mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-01-13 13:17:36 +03:00
tree: Document behavior if xmlSetTreeDoc fails
This commit is contained in:
parent
f1e9c7bdf1
commit
2a713a8091
11
tree.c
11
tree.c
@ -3081,6 +3081,13 @@ xmlInsertNode(xmlDocPtr doc, xmlNodePtr cur, xmlNodePtr parent,
|
||||
|
||||
if (cur->doc != doc) {
|
||||
if (xmlSetTreeDoc(cur, doc) < 0) {
|
||||
/*
|
||||
* We shouldn't make any modifications to the inserted
|
||||
* tree if a memory allocation fails, but that's hard to
|
||||
* implement. The tree has been moved to the target
|
||||
* document now but some contents are corrupted.
|
||||
* Unlinking is the best we can do.
|
||||
*/
|
||||
cur->parent = NULL;
|
||||
cur->prev = NULL;
|
||||
cur->next = NULL;
|
||||
@ -3333,6 +3340,10 @@ xmlAddChildList(xmlNodePtr parent, xmlNodePtr cur) {
|
||||
* document, document fragments, elements and attributes
|
||||
* should be used as parent nodes.
|
||||
*
|
||||
* When moving a node between documents and a memory allocation
|
||||
* fails, the node's content will be corrupted and it will be
|
||||
* unlinked. In this case, the node must be freed manually.
|
||||
*
|
||||
* Moving DTDs between documents isn't supported.
|
||||
*
|
||||
* Returns @elem or a sibling if @elem was merged. Returns NULL
|
||||
|
Loading…
x
Reference in New Issue
Block a user