[libxml2] Fix leak on SAX1, xmllint --sax1 option and debug



commit 023d0babc41da367f9272d4acc825bdd862f7a9c
Author: Daniel Veillard <veillard redhat com>
Date:   Wed Jul 29 11:34:50 2009 +0200

    Fix leak on SAX1, xmllint --sax1 option and debug
    
    * SAX2.c: don't leak in xmlCheckDefaultedAttributes for standalone
      checking
    * xmllint.c: fix xmllint --sax1 to actually use XML_PARSE_SAX1
    * debugXML.c: don't raise an error if markup wasn't allocated from
      dictionary if document was parsed with option disabling it

 SAX2.c     |    1 +
 debugXML.c |    4 +++-
 xmllint.c  |    7 ++++---
 3 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/SAX2.c b/SAX2.c
index 8dc1d58..e5d6eb5 100644
--- a/SAX2.c
+++ b/SAX2.c
@@ -1446,6 +1446,7 @@ process_external_subset:
 				    (const char *)fulln,
 				    (const char *)attr->elem);
 		    }
+                    xmlFree(fulln);
 		}
 		attr = attr->nexth;
 	    }
diff --git a/debugXML.c b/debugXML.c
index b56651b..76134cc 100644
--- a/debugXML.c
+++ b/debugXML.c
@@ -259,7 +259,9 @@ xmlCtxtCheckName(xmlDebugCtxtPtr ctxt, const xmlChar * name)
 			 "Name is not an NCName '%s'", (const char *) name);
 	}
 	if ((ctxt->dict != NULL) &&
-	    (!xmlDictOwns(ctxt->dict, name))) {
+	    (!xmlDictOwns(ctxt->dict, name)) &&
+            ((ctxt->doc == NULL) ||
+             ((ctxt->doc->parseFlags & (XML_PARSE_SAX1 | XML_PARSE_NODICT)) == 0))) {
 	    xmlDebugErr3(ctxt, XML_CHECK_OUTSIDE_DICT,
 			 "Name is not from the document dictionnary '%s'",
 			 (const char *) name);
diff --git a/xmllint.c b/xmllint.c
index a668570..c324ef3 100644
--- a/xmllint.c
+++ b/xmllint.c
@@ -3221,16 +3221,17 @@ main(int argc, char **argv) {
 #ifdef LIBXML_SAX1_ENABLED
 	else if ((!strcmp(argv[i], "-sax1")) ||
 	         (!strcmp(argv[i], "--sax1"))) {
-	     sax1++;
+	    sax1++;
+	    options |= XML_PARSE_SAX1;
 	}
 #endif /* LIBXML_SAX1_ENABLED */
 	else if ((!strcmp(argv[i], "-sax")) ||
 	         (!strcmp(argv[i], "--sax"))) {
-	     sax++;
+	    sax++;
 	}
 	else if ((!strcmp(argv[i], "-chkregister")) ||
 	         (!strcmp(argv[i], "--chkregister"))) {
-	     chkregister++;
+	    chkregister++;
 #ifdef LIBXML_SCHEMAS_ENABLED
 	} else if ((!strcmp(argv[i], "-relaxng")) ||
 	         (!strcmp(argv[i], "--relaxng"))) {



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