1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-01-15 23:24:06 +03:00

malloc-fail: Fix memory leak in xmlNewPropInternal

Also fixes a memory leak if called with a non-element node.

Found with libFuzzer, see #344.
This commit is contained in:
Nick Wellnhofer 2022-11-02 15:53:52 +01:00
parent 865e142c41
commit fa361de0b7

3
tree.c
View File

@ -1860,7 +1860,7 @@ xmlNewPropInternal(xmlNodePtr node, xmlNsPtr ns,
if ((node != NULL) && (node->type != XML_ELEMENT_NODE)) {
if ((eatname == 1) &&
((node->doc == NULL) ||
((node->doc == NULL) || (node->doc->dict == NULL) ||
(!(xmlDictOwns(node->doc->dict, name)))))
xmlFree((xmlChar *) name);
return (NULL);
@ -1873,6 +1873,7 @@ xmlNewPropInternal(xmlNodePtr node, xmlNsPtr ns,
if (cur == NULL) {
if ((eatname == 1) &&
((node == NULL) || (node->doc == NULL) ||
(node->doc->dict == NULL) ||
(!(xmlDictOwns(node->doc->dict, name)))))
xmlFree((xmlChar *) name);
xmlTreeErrMemory("building attribute");