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

Unlink node before freeing it in xmlSAX2StartElement

The node may have been added to the document already, so it must be
unlinked first. Thanks to David Kilzer for spotting this.
This commit is contained in:
Nick Wellnhofer 2018-09-22 15:41:01 +02:00
parent 8c9daf790a
commit 0ed6addb8f

2
SAX2.c
View File

@ -1666,6 +1666,7 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
xmlGenericError(xmlGenericErrorContext, "pushing(%s)\n", name);
#endif
if (nodePush(ctxt, ret) < 0) {
xmlUnlinkNode(ret);
xmlFreeNode(ret);
return;
}
@ -2340,6 +2341,7 @@ xmlSAX2StartElementNs(void *ctx,
* We are parsing a new node.
*/
if (nodePush(ctxt, ret) < 0) {
xmlUnlinkNode(ret);
xmlFreeNode(ret);
return;
}