Merge branch 'tizen_base' of ssh://review.tizen.org:29418/platform/upstream/libxml2...
[platform/upstream/libxml2.git] / SAX2.c
diff --git a/SAX2.c b/SAX2.c
index 5cbb700..0f261b7 100644 (file)
--- a/SAX2.c
+++ b/SAX2.c
@@ -12,6 +12,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <limits.h>
+#include <stddef.h>
 #include <libxml/xmlmemory.h>
 #include <libxml/tree.h>
 #include <libxml/parser.h>
@@ -1181,6 +1182,8 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
                xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement");
                if (name != NULL)
                    xmlFree(name);
+                if (nval != NULL)
+                    xmlFree(nval);
                return;
            }
        } else {
@@ -1242,6 +1245,8 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
                xmlFree(ns);
                if (name != NULL)
                    xmlFree(name);
+                if (nval != NULL)
+                    xmlFree(nval);
                return;
            }
        } else {
@@ -1311,6 +1316,8 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
                                              name, namespace->href);
                         ctxt->wellFormed = 0;
                         if (ctxt->recovery == 0) ctxt->disableSAX = 1;
+                        if (name != NULL)
+                            xmlFree(name);
                         goto error;
                     }
                 }
@@ -1908,7 +1915,7 @@ skip:
            else {
                ret->line = 65535;
                if (ctxt->options & XML_PARSE_BIG_LINES)
-                   ret->psvi = (void *) (long) ctxt->input->line;
+                   ret->psvi = (void *) (ptrdiff_t) ctxt->input->line;
            }
        }
     }
@@ -2311,7 +2318,7 @@ xmlSAX2StartElementNs(void *ctx,
        } else {
             /*
              * any out of memory error would already have been raised
-             * but we can't be garanteed it's the actual error due to the
+             * but we can't be guaranteed it's the actual error due to the
              * API, best is to skip in this case
              */
            continue;
@@ -2805,7 +2812,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);
     }
 }