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/tree.c b/tree.c
index 867f074..b2445f0 100644
--- a/tree.c
+++ b/tree.c
@@ -193,6 +193,7 @@
xmlChar *ret = NULL;
*prefix = NULL;
+ if (name == NULL) return(NULL);
#ifndef XML_XML_NAMESPACE
/* xml: prefix is not really a namespace */
@@ -216,7 +217,21 @@
return(NULL);
*prefix = xmlStrndup(name, len);
+ if (*prefix == NULL) {
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlSplitQName2 : out of memory!\n");
+ return(NULL);
+ }
ret = xmlStrdup(&name[len + 1]);
+ if (ret == NULL) {
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlSplitQName2 : out of memory!\n");
+ if (*prefix != NULL) {
+ xmlFree(*prefix);
+ *prefix = NULL;
+ }
+ return(NULL);
+ }
return(ret);
}
@@ -1670,6 +1685,7 @@
if (cur == NULL) {
xmlGenericError(xmlGenericErrorContext,
"xmlNewNsPropEatName : malloc failed\n");
+ xmlFree(name);
return(NULL);
}
memset(cur, 0, sizeof(xmlAttr));
@@ -1988,6 +2004,7 @@
if (cur == NULL) {
xmlGenericError(xmlGenericErrorContext,
"xmlNewNode : malloc failed\n");
+ xmlFree(name);
return(NULL);
}
memset(cur, 0, sizeof(xmlNode));
@@ -6047,11 +6064,13 @@
* @len: @content length
*
* Concat the given string at the end of the existing node content
+ *
+ * Returns -1 in case of error, 0 otherwise
*/
-void
+int
xmlTextConcat(xmlNodePtr node, const xmlChar *content, int len) {
- if (node == NULL) return;
+ if (node == NULL) return(-1);
if ((node->type != XML_TEXT_NODE) &&
(node->type != XML_CDATA_SECTION_NODE)) {
@@ -6059,9 +6078,12 @@
xmlGenericError(xmlGenericErrorContext,
"xmlTextConcat: node is not text nor CDATA\n");
#endif
- return;
+ return(-1);
}
node->content = xmlStrncat(node->content, content, len);
+ if (node->content == NULL)
+ return(-1);
+ return(0);
}
/************************************************************************