summaryrefslogtreecommitdiff
path: root/relaxng.c
diff options
context:
space:
mode:
Diffstat (limited to 'relaxng.c')
-rw-r--r--relaxng.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/relaxng.c b/relaxng.c
index ae6c63d..af4de86 100644
--- a/relaxng.c
+++ b/relaxng.c
@@ -248,6 +248,7 @@ struct _xmlRelaxNGParserCtxt {
xmlAutomataStatePtr state; /* used to build the automata */
int crng; /* compact syntax and other flags */
+ int freedoc; /* need to free the document */
};
#define FLAGS_IGNORABLE 1
@@ -2781,7 +2782,7 @@ xmlRelaxNGRegisterTypeLibrary(const xmlChar * namespace, void *data,
*
* Returns 0 in case of success and -1 in case of error.
*/
-static int
+int
xmlRelaxNGInitTypes(void)
{
if (xmlRelaxNGTypeInitialized != 0)
@@ -6657,6 +6658,7 @@ xmlRelaxNGNewDocParserCtxt(xmlDocPtr doc)
}
memset(ret, 0, sizeof(xmlRelaxNGParserCtxt));
ret->document = copy;
+ ret->freedoc = 1;
ret->userData = xmlGenericErrorContext;
return (ret);
}
@@ -6693,6 +6695,8 @@ xmlRelaxNGFreeParserCtxt(xmlRelaxNGParserCtxtPtr ctxt)
xmlRelaxNGFreeDefine(ctxt->defTab[i]);
xmlFree(ctxt->defTab);
}
+ if ((ctxt->document != NULL) && (ctxt->freedoc))
+ xmlFreeDoc(ctxt->document);
xmlFree(ctxt);
}
@@ -7671,6 +7675,8 @@ xmlRelaxNGDumpGrammar(FILE * output, xmlRelaxNGGrammarPtr grammar, int top)
void
xmlRelaxNGDump(FILE * output, xmlRelaxNGPtr schema)
{
+ if (output == NULL)
+ return;
if (schema == NULL) {
fprintf(output, "RelaxNG empty or failed to compile\n");
return;
@@ -7700,6 +7706,8 @@ xmlRelaxNGDump(FILE * output, xmlRelaxNGPtr schema)
void
xmlRelaxNGDumpTree(FILE * output, xmlRelaxNGPtr schema)
{
+ if (output == NULL)
+ return;
if (schema == NULL) {
fprintf(output, "RelaxNG empty or failed to compile\n");
return;