integrated the Out Of Memory test from Havoc Pennington #109368 a lot of
* Makefile.am testOOM.c testOOMlib.[ch] : integrated the Out Of
Memory test from Havoc Pennington #109368
* SAX.c parser.c parserInternals.c tree.c uri.c valid.c
xmlmemory.c xmlreader.c xmlregexp.c include/libxml/tree.h
include/libxml/parser.h: a lot of memory allocation cleanups
based on the results of the OOM testing
* check-relaxng-test-suite2.py: seems I forgot to commit the
script.
Daniel
diff --git a/parserInternals.c b/parserInternals.c
index 8b574f2..1e2777d 100644
--- a/parserInternals.c
+++ b/parserInternals.c
@@ -2166,15 +2166,17 @@
* @ctxt: an XML parser context
*
* Initialize a parser context
+ *
+ * Returns 0 in case of success and -1 in case of error
*/
-void
+int
xmlInitParserCtxt(xmlParserCtxtPtr ctxt)
{
if(ctxt==NULL) {
xmlGenericError(xmlGenericErrorContext,
"xmlInitParserCtxt: NULL context given\n");
- return;
+ return(-1);
}
xmlDefaultSAXHandlerInit();
@@ -2183,6 +2185,7 @@
if (ctxt->sax == NULL) {
xmlGenericError(xmlGenericErrorContext,
"xmlInitParserCtxt: out of memory\n");
+ return(-1);
}
else
memcpy(ctxt->sax, &xmlDefaultSAXHandler, sizeof(xmlSAXHandler));
@@ -2196,7 +2199,7 @@
ctxt->inputNr = 0;
ctxt->inputMax = 0;
ctxt->input = NULL;
- return;
+ return(-1);
}
ctxt->inputNr = 0;
ctxt->inputMax = 5;
@@ -2224,7 +2227,7 @@
ctxt->inputNr = 0;
ctxt->inputMax = 0;
ctxt->input = NULL;
- return;
+ return(-1);
}
ctxt->nodeNr = 0;
ctxt->nodeMax = 10;
@@ -2244,7 +2247,7 @@
ctxt->nameNr = 0;
ctxt->nameMax = 0;
ctxt->name = NULL;
- return;
+ return(-1);
}
ctxt->nameNr = 0;
ctxt->nameMax = 10;
@@ -2267,7 +2270,7 @@
ctxt->spaceNr = 0;
ctxt->spaceMax = 0;
ctxt->space = NULL;
- return;
+ return(-1);
}
ctxt->spaceNr = 1;
ctxt->spaceMax = 10;
@@ -2305,6 +2308,7 @@
ctxt->charset = XML_CHAR_ENCODING_UTF8;
ctxt->catalogs = NULL;
xmlInitNodeInfoSeq(&ctxt->node_seq);
+ return(0);
}
/**
@@ -2370,7 +2374,10 @@
return(NULL);
}
memset(ctxt, 0, sizeof(xmlParserCtxt));
- xmlInitParserCtxt(ctxt);
+ if (xmlInitParserCtxt(ctxt) < 0) {
+ xmlFreeParserCtxt(ctxt);
+ return(NULL);
+ }
return(ctxt);
}