1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 12:25:09 +03:00

xinclude: Report malloc failures in xmlXIncludeIncludeNode

This commit is contained in:
Nick Wellnhofer 2024-03-22 12:26:28 +01:00
parent 7b316c1139
commit 0d04d79cd4

View File

@ -1960,7 +1960,11 @@ xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, xmlXIncludeRefPtr ref) {
end = list;
list = list->next;
xmlAddPrevSibling(cur, end);
if (xmlAddPrevSibling(cur, end) == NULL) {
xmlUnlinkNode(end);
xmlFreeNode(end);
goto err_memory;
}
}
/*
* FIXME: xmlUnlinkNode doesn't coalesce text nodes.
@ -1984,13 +1988,13 @@ xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, xmlXIncludeRefPtr ref) {
xmlFreeNode(child);
}
end = xmlNewDocNode(cur->doc, cur->ns, cur->name, NULL);
if (end == NULL) {
xmlXIncludeErrMemory(ctxt);
xmlFreeNodeList(list);
return(-1);
}
if (end == NULL)
goto err_memory;
end->type = XML_XINCLUDE_END;
xmlAddNextSibling(cur, end);
if (xmlAddNextSibling(cur, end) == NULL) {
xmlFreeNode(end);
goto err_memory;
}
/*
* Add the list of nodes
@ -1999,12 +2003,21 @@ xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, xmlXIncludeRefPtr ref) {
cur = list;
list = list->next;
xmlAddPrevSibling(end, cur);
if (xmlAddPrevSibling(end, cur) == NULL) {
xmlUnlinkNode(cur);
xmlFreeNode(cur);
goto err_memory;
}
}
}
return(0);
err_memory:
xmlXIncludeErrMemory(ctxt);
xmlFreeNodeList(list);
return(-1);
}
/**