summaryrefslogtreecommitdiff
path: root/SAX2.c
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2018-09-22 15:41:01 +0200
committerNick Wellnhofer <wellnhofer@aevum.de>2018-09-22 15:41:01 +0200
commit0ed6addb8f165ae533fbe812e4a973c7b682ec7e (patch)
treea9435821a8762f3cf0708a760563bfcbaff6dafa /SAX2.c
parent8c9daf790abfc06e8ca3a44652542c577bb67d49 (diff)
downloadlibxml2-0ed6addb8f165ae533fbe812e4a973c7b682ec7e.tar.gz
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.
Diffstat (limited to 'SAX2.c')
-rw-r--r--SAX2.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/SAX2.c b/SAX2.c
index 49ce566c..ac3ab19a 100644
--- a/SAX2.c
+++ b/SAX2.c
@@ -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;
}