libxml2 r3816 - trunk



Author: veillard
Date: Fri Feb 20 08:19:53 2009
New Revision: 3816
URL: http://svn.gnome.org/viewvc/libxml2?rev=3816&view=rev

Log:
* xmlwriter.c: remove a couple of leaks on errors reported by
  Jinmei Tatuya
daniel


Modified:
   trunk/ChangeLog
   trunk/xmlwriter.c

Modified: trunk/xmlwriter.c
==============================================================================
--- trunk/xmlwriter.c	(original)
+++ trunk/xmlwriter.c	Fri Feb 20 08:19:53 2009
@@ -370,7 +370,7 @@
     ctxt = xmlCreatePushParserCtxt(&saxHandler, NULL, NULL, 0, NULL);
     if (ctxt == NULL) {
         xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR,
-                        "xmlNewTextWriterDoc : error at xmlCreatePushParserCtxt!\n");
+                "xmlNewTextWriterDoc : error at xmlCreatePushParserCtxt!\n");
         return NULL;
     }
     /*
@@ -389,8 +389,10 @@
 
     ret = xmlNewTextWriterPushParser(ctxt, compression);
     if (ret == NULL) {
+        xmlFreeDoc(ctxt->myDoc);
+        xmlFreeParserCtxt(ctxt);
         xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR,
-                        "xmlNewTextWriterDoc : error at xmlNewTextWriterPushParser!\n");
+                "xmlNewTextWriterDoc : error at xmlNewTextWriterPushParser!\n");
         return NULL;
     }
 
@@ -1510,12 +1512,13 @@
 
     if (buf != NULL) {
         count = xmlTextWriterWriteRaw(writer, buf);
-        if (count < 0)
-            return -1;
-        sum += count;
 
         if (buf != content)     /* buf was allocated by us, so free it */
             xmlFree(buf);
+
+        if (count < 0)
+            return -1;
+        sum += count;
     }
 
     return sum;



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