added a GROW when parsing complex comments (bug #405666) added a hack to

* parser.c: added a GROW when parsing complex comments (bug #405666)
* gentest.py, testapi.c: added a hack to prevent destruction of any
  param with 'destroy' in it's description (i.e. param destroyed by
  the routine under test, so shouldn't be destroyed by testapi)
* xmlreader.c: added freeing of 'input' param even on error

svn path=/trunk/; revision=3579
diff --git a/ChangeLog b/ChangeLog
index a0ef00e..595ff56 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Thu Feb 08 15:35:18 PST 2007 William Brack <wbrack@mmm.com.hk>
+
+	* parser.c: added a GROW when parsing complex comments (bug #405666)
+	* gentest.py, testapi.c: added a hack to prevent destruction of any
+	  param with 'destroy' in it's description (i.e. param destroyed by
+	  the routine under test, so shouldn't be destroyed by testapi)
+	* xmlreader.c: added freeing of 'input' param even on error
+	  (fixes leak detected by testapi)
+
 Wed Jan 31 10:25:38 PST 2007 William Brack <wbrack@mmm.com.hk>
 
 	* testAutomata.c, testRegexp.c, testThreads.c, testThreadsWin32.c,
diff --git a/gentest.py b/gentest.py
index 8c143af..4538eb8 100755
--- a/gentest.py
+++ b/gentest.py
@@ -819,11 +819,14 @@
     i = 0;
     for arg in t_args:
         (nam, type, rtype, crtype, info) = arg;
-	#
-	test.write("        des_%s(n_%s, " % (type, nam))
-	if rtype != crtype:
-	    test.write("(%s)" % rtype)
-	test.write("%s, %d);\n" % (nam, i))
+	# This is a hack to prevent generating a destructor for the
+	# 'input' argument in xmlTextReaderSetup.  There should be
+	# a better, more generic way to do this!
+	if string.find(info, 'destroy') == -1:
+	    test.write("        des_%s(n_%s, " % (type, nam))
+	    if rtype != crtype:
+	        test.write("(%s)" % rtype)
+	    test.write("%s, %d);\n" % (nam, i))
 	i = i + 1;
 
     test.write("        xmlResetLastError();\n");
diff --git a/parser.c b/parser.c
index 32927eb..456cab9 100644
--- a/parser.c
+++ b/parser.c
@@ -3808,6 +3808,7 @@
 	    return;
 	}
     }
+;    GROW;	/* Assure there's enough input data */
     q = CUR_CHAR(ql);
     if (q == 0)
         goto not_terminated;
diff --git a/xmlreader.c b/xmlreader.c
index 1dc5af1..fe19875 100644
--- a/xmlreader.c
+++ b/xmlreader.c
@@ -4167,9 +4167,9 @@
  *
  * Use RelaxNG to validate the document as it is processed.
  * Activation is only possible before the first Read().
- * if @rng is NULL, then RelaxNG validation is desactivated.
+ * if @rng is NULL, then RelaxNG validation is deactivated.
  *
- * Returns 0 in case the RelaxNG validation could be (des)activated and
+ * Returns 0 in case the RelaxNG validation could be (de)activated and
  *         -1 in case of error.
  */
 int
@@ -4207,8 +4207,8 @@
 			 xmlTextReaderValidityWarningRelay,
 			 reader);
     }
-	if (reader->sErrorFunc != NULL) {
-		xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt, 
+    if (reader->sErrorFunc != NULL) {
+	xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt, 
 			xmlTextReaderValidityStructuredRelay,
 			reader);
     }
@@ -4861,8 +4861,11 @@
                    xmlParserInputBufferPtr input, const char *URL,
                    const char *encoding, int options)
 {
-    if (reader == NULL)
-        return (-1);
+    if (reader == NULL) {
+/*        if (input != NULL)
+	    xmlFreeParserInputBuffer(input);
+*/        return (-1);
+    }
 
     /*
      * we force the generation of compact text nodes on the reader