mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-24 13:33:01 +03:00
tree: Fix xmlTextMerge with NULL args
Restore pre-2.13 behavior. Fixes #875.
This commit is contained in:
11
fuzz/api.c
11
fuzz/api.c
@@ -2461,11 +2461,14 @@ LLVMFuzzerTestOneInput(const char *data, size_t size) {
|
|||||||
first = getNode(0);
|
first = getNode(0);
|
||||||
second = getNode(1);
|
second = getNode(1);
|
||||||
argsOk =
|
argsOk =
|
||||||
(first != NULL && first->type == XML_TEXT_NODE &&
|
first == NULL ?
|
||||||
second != NULL && second->type == XML_TEXT_NODE &&
|
second != NULL :
|
||||||
|
second == NULL ||
|
||||||
|
(first->type == XML_TEXT_NODE &&
|
||||||
|
second->type == XML_TEXT_NODE &&
|
||||||
first != second &&
|
first != second &&
|
||||||
first->name == second->name);
|
first->name == second->name);
|
||||||
if (argsOk) {
|
if (argsOk && second != NULL) {
|
||||||
if (second->parent != NULL)
|
if (second->parent != NULL)
|
||||||
parent = second->parent;
|
parent = second->parent;
|
||||||
else
|
else
|
||||||
@@ -2474,7 +2477,7 @@ LLVMFuzzerTestOneInput(const char *data, size_t size) {
|
|||||||
}
|
}
|
||||||
res = xmlTextMerge(first, second);
|
res = xmlTextMerge(first, second);
|
||||||
oomReport = (argsOk && res == NULL);
|
oomReport = (argsOk && res == NULL);
|
||||||
if (res != NULL) {
|
if (res != NULL && first != NULL) {
|
||||||
removeNode(second);
|
removeNode(second);
|
||||||
dropNode(parent);
|
dropNode(parent);
|
||||||
checkContent(first);
|
checkContent(first);
|
||||||
|
|||||||
14
tree.c
14
tree.c
@@ -5790,15 +5790,21 @@ xmlNodeAddContent(xmlNodePtr cur, const xmlChar *content) {
|
|||||||
* @first: the first text node
|
* @first: the first text node
|
||||||
* @second: the second text node being merged
|
* @second: the second text node being merged
|
||||||
*
|
*
|
||||||
* Merge the second text node into the first. The second node is
|
* Merge the second text node into the first. If @first is NULL,
|
||||||
* unlinked and freed.
|
* @second is returned. Otherwise, the second node is unlinked and
|
||||||
|
* freed.
|
||||||
*
|
*
|
||||||
* Returns the first text node augmented or NULL in case of error.
|
* Returns the first text node augmented or NULL in case of error.
|
||||||
*/
|
*/
|
||||||
xmlNodePtr
|
xmlNodePtr
|
||||||
xmlTextMerge(xmlNodePtr first, xmlNodePtr second) {
|
xmlTextMerge(xmlNodePtr first, xmlNodePtr second) {
|
||||||
if ((first == NULL) || (first->type != XML_TEXT_NODE) ||
|
if (first == NULL)
|
||||||
(second == NULL) || (second->type != XML_TEXT_NODE) ||
|
return(second);
|
||||||
|
if (second == NULL)
|
||||||
|
return(first);
|
||||||
|
|
||||||
|
if ((first->type != XML_TEXT_NODE) ||
|
||||||
|
(second->type != XML_TEXT_NODE) ||
|
||||||
(first == second) ||
|
(first == second) ||
|
||||||
(first->name != second->name))
|
(first->name != second->name))
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
|||||||
Reference in New Issue
Block a user