found and fixed a couple of allocation bugs Daniel
* parser.c valid.c: found and fixed a couple of allocation bugs
Daniel
diff --git a/ChangeLog b/ChangeLog
index 7a8a5d8..2fa9e18 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Wed Feb 20 17:47:55 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+ * parser.c valid.c: found and fixed a couple of allocation bugs
+
Wed Feb 20 15:36:03 CET 2002 Daniel Veillard <daniel@veillard.com>
* doc/xml.html doc/python.html doc/*: added a Python and binding
diff --git a/parser.c b/parser.c
index 09833e0..e07ca38 100644
--- a/parser.c
+++ b/parser.c
@@ -4349,10 +4349,7 @@
type);
ctxt->wellFormed = 0;
ctxt->disableSAX = 1;
- if ((op != NULL) && (op != ret))
- xmlFreeElementContent(op);
- if ((last != NULL) && (last != ret) &&
- (last != ret->c1) && (last != ret->c2))
+ if ((last != NULL) && (last != ret))
xmlFreeElementContent(last);
if (ret != NULL)
xmlFreeElementContent(ret);
@@ -4362,6 +4359,8 @@
op = xmlNewElementContent(NULL, XML_ELEMENT_CONTENT_SEQ);
if (op == NULL) {
+ if ((last != NULL) && (last != ret))
+ xmlFreeElementContent(last);
xmlFreeElementContent(ret);
return(NULL);
}
@@ -4394,10 +4393,7 @@
type);
ctxt->wellFormed = 0;
ctxt->disableSAX = 1;
- if ((op != NULL) && (op != ret) && (op != last))
- xmlFreeElementContent(op);
- if ((last != NULL) && (last != ret) &&
- (last != ret->c1) && (last != ret->c2))
+ if ((last != NULL) && (last != ret))
xmlFreeElementContent(last);
if (ret != NULL)
xmlFreeElementContent(ret);
@@ -4407,10 +4403,7 @@
op = xmlNewElementContent(NULL, XML_ELEMENT_CONTENT_OR);
if (op == NULL) {
- if ((op != NULL) && (op != ret))
- xmlFreeElementContent(op);
- if ((last != NULL) && (last != ret) &&
- (last != ret->c1) && (last != ret->c2))
+ if ((last != NULL) && (last != ret))
xmlFreeElementContent(last);
if (ret != NULL)
xmlFreeElementContent(ret);
@@ -4438,11 +4431,6 @@
"xmlParseElementChildrenContentDecl : ',' '|' or ')' expected\n");
ctxt->wellFormed = 0;
ctxt->disableSAX = 1;
- if ((op != NULL) && (op != ret))
- xmlFreeElementContent(op);
- if ((last != NULL) && (last != ret) &&
- (last != ret->c1) && (last != ret->c2))
- xmlFreeElementContent(last);
if (ret != NULL)
xmlFreeElementContent(ret);
return(NULL);
@@ -4466,11 +4454,6 @@
"xmlParseElementChildrenContentDecl : Name or '(' expected\n");
ctxt->wellFormed = 0;
ctxt->disableSAX = 1;
- if ((op != NULL) && (op != ret))
- xmlFreeElementContent(op);
- if ((last != NULL) && (last != ret) &&
- (last != ret->c1) && (last != ret->c2))
- xmlFreeElementContent(last);
if (ret != NULL)
xmlFreeElementContent(ret);
return(NULL);
diff --git a/valid.c b/valid.c
index c6db9e4..bb0bf8b 100644
--- a/valid.c
+++ b/valid.c
@@ -421,6 +421,7 @@
"xmlNewElementContent : out of memory!\n");
return(NULL);
}
+ memset(ret, 0, sizeof(xmlElementContent));
ret->type = type;
ret->ocur = XML_ELEMENT_CONTENT_ONCE;
if (name != NULL) {