fixed the leak reported by Volker Roth on the list added a specific test
* parser.c: fixed the leak reported by Volker Roth on the list
* test/ent10 result//ent10*: added a specific test for the problem
Daniel
diff --git a/ChangeLog b/ChangeLog
index b7c0bda..e880548 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Oct 25 17:11:37 CEST 2004 Daniel Veillard <daniel@veillard.com>
+
+ * parser.c: fixed the leak reported by Volker Roth on the list
+ * test/ent10 result//ent10*: added a specific test for the problem
+
Sat Oct 23 11:07:41 PDT 2004 William Brack <wbrack@mmm.com.hk>
* valid.c: unlinked the internal subset within xmlValidateDtd
diff --git a/error.c b/error.c
index b0660d8..9b8ddc4 100644
--- a/error.c
+++ b/error.c
@@ -453,7 +453,7 @@
return;
if ((domain == XML_FROM_PARSER) || (domain == XML_FROM_HTML) ||
(domain == XML_FROM_DTD) || (domain == XML_FROM_NAMESPACE) ||
- (domain == XML_FROM_IO)) {
+ (domain == XML_FROM_IO) || (domain == XML_FROM_VALID)) {
ctxt = (xmlParserCtxtPtr) ctx;
if ((schannel == NULL) && (ctxt != NULL) && (ctxt->sax != NULL) &&
(ctxt->sax->initialized == XML_SAX2_MAGIC))
diff --git a/parser.c b/parser.c
index f7d971f..053fdc3 100644
--- a/parser.c
+++ b/parser.c
@@ -5692,16 +5692,20 @@
xmlAddEntityReference(ent, firstChild, nw);
#endif /* LIBXML_LEGACY_ENABLED */
} else {
+ const xmlChar *nbktext;
+
/*
* the name change is to avoid coalescing of the
* node with a possible previous text one which
* would make ent->children a dangling pointer
*/
+ nbktext = xmlDictLookup(ctxt->dict, BAD_CAST "nbktext",
+ -1);
if (ent->children->type == XML_TEXT_NODE)
- ent->children->name = xmlStrdup(BAD_CAST "nbktext");
+ ent->children->name = nbktext;
if ((ent->last != ent->children) &&
(ent->last->type == XML_TEXT_NODE))
- ent->last->name = xmlStrdup(BAD_CAST "nbktext");
+ ent->last->name = nbktext;
xmlAddChildList(ctxt->node, ent->children);
}
diff --git a/result/ent10 b/result/ent10
new file mode 100644
index 0000000..c46d19f
--- /dev/null
+++ b/result/ent10
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE rnode [
+<!ELEMENT rnode (f)>
+<!ELEMENT f (#PCDATA)>
+<!ATTLIST f att1 CDATA #FIXED "J">
+<!ENTITY f "
+ <f>
+ hello world
+ </f>
+ ">
+]>
+<rnode>
+ &f;
+</rnode>
diff --git a/result/ent10.rde b/result/ent10.rde
new file mode 100644
index 0000000..e69594c
--- /dev/null
+++ b/result/ent10.rde
@@ -0,0 +1,14 @@
+0 10 rnode 0 0
+0 1 rnode 0 0
+1 14 #text 0 1
+
+
+1 1 f 0 0
+2 3 #text 0 1
+ hello world
+
+1 15 f 0 0
+1 14 #text 0 1
+
+
+0 15 rnode 0 0
diff --git a/result/ent10.rdr b/result/ent10.rdr
new file mode 100644
index 0000000..34edb50
--- /dev/null
+++ b/result/ent10.rdr
@@ -0,0 +1,8 @@
+0 10 rnode 0 0
+0 1 rnode 0 0
+1 14 #text 0 1
+
+1 5 f 0 0
+1 14 #text 0 1
+
+0 15 rnode 0 0
diff --git a/result/ent10.sax b/result/ent10.sax
new file mode 100644
index 0000000..75ed20a
--- /dev/null
+++ b/result/ent10.sax
@@ -0,0 +1,31 @@
+SAX.setDocumentLocator()
+SAX.startDocument()
+SAX.internalSubset(rnode, , )
+SAX.elementDecl(rnode, 4, ...)
+SAX.elementDecl(f, 3, ...)
+SAX.attributeDecl(f, att1, 1, 4, J, ...)
+SAX.entityDecl(f, 1, (null), (null),
+ <f>
+ hello world
+ </f>
+ )
+SAX.getEntity(f)
+SAX.externalSubset(rnode, , )
+SAX.startElement(rnode)
+SAX.characters(
+ , 4)
+SAX.getEntity(f)
+SAX.ignorableWhitespace(
+ , 4)
+SAX.startElement(f)
+SAX.characters(
+ hello world
+ , 19)
+SAX.endElement(f)
+SAX.characters(
+ , 4)
+SAX.reference(f)
+SAX.characters(
+, 1)
+SAX.endElement(rnode)
+SAX.endDocument()
diff --git a/result/noent/ent10 b/result/noent/ent10
new file mode 100644
index 0000000..946aff8
--- /dev/null
+++ b/result/noent/ent10
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE rnode [
+<!ELEMENT rnode (f)>
+<!ELEMENT f (#PCDATA)>
+<!ATTLIST f att1 CDATA #FIXED "J">
+<!ENTITY f "
+ <f>
+ hello world
+ </f>
+ ">
+]>
+<rnode>
+
+ <f>
+ hello world
+ </f>
+
+</rnode>
diff --git a/test/ent10 b/test/ent10
new file mode 100644
index 0000000..4778d89
--- /dev/null
+++ b/test/ent10
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE rnode [
+<!ELEMENT rnode (f)>
+
+<!ELEMENT f (#PCDATA)>
+<!ATTLIST f
+ att1 CDATA #FIXED 'J'>
+
+<!ENTITY f
+ "
+ <f>
+ hello world
+ </f>
+ "
+>
+]>
+
+<rnode>
+ &f;
+</rnode>
+
diff --git a/tree.c b/tree.c
index 87c4556..bf112ca 100644
--- a/tree.c
+++ b/tree.c
@@ -5081,7 +5081,7 @@
case XML_COMMENT_NODE:
if (cur->content != NULL) {
if (!((cur->doc != NULL) && (cur->doc->dict != NULL) &&
- xmlDictOwns(cur->doc->dict, cur->content)))
+ (!xmlDictOwns(cur->doc->dict, cur->content))))
xmlFree(cur->content);
}
if (cur->children != NULL) xmlFreeNodeList(cur->children);