1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-21 14:53:44 +03:00

tree: Fix xmlTextMerge with NULL args

Restore pre-2.13 behavior. Fixes #875.
This commit is contained in:
Nick Wellnhofer
2025-03-18 11:11:20 +01:00
parent 54c3d42891
commit dd4c0f62fa
2 changed files with 19 additions and 10 deletions

14
tree.c
View File

@@ -5790,15 +5790,21 @@ xmlNodeAddContent(xmlNodePtr cur, const xmlChar *content) {
* @first: the first text node
* @second: the second text node being merged
*
* Merge the second text node into the first. The second node is
* unlinked and freed.
* Merge the second text node into the first. If @first is NULL,
* @second is returned. Otherwise, the second node is unlinked and
* freed.
*
* Returns the first text node augmented or NULL in case of error.
*/
xmlNodePtr
xmlTextMerge(xmlNodePtr first, xmlNodePtr second) {
if ((first == NULL) || (first->type != XML_TEXT_NODE) ||
(second == NULL) || (second->type != XML_TEXT_NODE) ||
if (first == NULL)
return(second);
if (second == NULL)
return(first);
if ((first->type != XML_TEXT_NODE) ||
(second->type != XML_TEXT_NODE) ||
(first == second) ||
(first->name != second->name))
return(NULL);