[libxml2] Do not leak the new CData node if adding fails



commit 074180119fc90d5fd04ef9e8a5ee1910d6f9ad8e
Author: David Tardon <dtardon redhat com>
Date:   Wed Apr 5 10:22:40 2017 +0200

    Do not leak the new CData node if adding fails
    
    For https://bugzilla.gnome.org/show_bug.cgi?id=780918

 SAX2.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/SAX2.c b/SAX2.c
index 5cbb700..0f0ad2a 100644
--- a/SAX2.c
+++ b/SAX2.c
@@ -2805,7 +2805,8 @@ xmlSAX2CDataBlock(void *ctx, const xmlChar *value, int len)
        xmlTextConcat(lastChild, value, len);
     } else {
        ret = xmlNewCDataBlock(ctxt->myDoc, value, len);
-       xmlAddChild(ctxt->node, ret);
+       if (xmlAddChild(ctxt->node, ret) == NULL)
+               xmlFreeNode(ret);
     }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]