patch from Dodji Seketeli to avoid a leak on repeated uses of

* xmlwriter.c: patch from Dodji Seketeli to avoid a leak on repeated
  uses of xmlTextWriterStartDocument()
Daniel

svn path=/trunk/; revision=3642
diff --git a/ChangeLog b/ChangeLog
index f0a09a6..27aa4d2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Jul  4 17:44:20 CEST 2007 Daniel Veillard <daniel@veillard.com>
+
+	* xmlwriter.c: patch from Dodji Seketeli to avoid a leak on repeated
+	  uses of xmlTextWriterStartDocument()
+
 Tue Jun 26 13:30:50 CEST 2007 Daniel Veillard <daniel@veillard.com>
 
 	* xmlschemas.c: fix a crash on solaris when a printf %s with a NULL
diff --git a/xmlwriter.c b/xmlwriter.c
index f618610..7acae76 100644
--- a/xmlwriter.c
+++ b/xmlwriter.c
@@ -545,7 +545,9 @@
 
     writer->out->encoder = encoder;
     if (encoder != NULL) {
-        writer->out->conv = xmlBufferCreateSize(4000);
+	if (writer->out->conv == NULL) {
+	    writer->out->conv = xmlBufferCreateSize(4000);
+	}
         xmlCharEncOutFunc(encoder, writer->out->conv, NULL);
         if ((writer->doc != NULL) && (writer->doc->encoding == NULL))
             writer->doc->encoding = xmlStrdup((xmlChar *)writer->out->encoder->name);