summaryrefslogtreecommitdiff
path: root/entities.c
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2002-12-30 00:01:08 +0000
committerDaniel Veillard <veillard@src.gnome.org>2002-12-30 00:01:08 +0000
commit2d84a89478ccf8e65d6ab94a919f403cc1968d47 (patch)
treed78d5484c64fd77237efd94ca6350589096187c1 /entities.c
parent29b3e285a70b9117619fef7ebfad94c2e44e2a1c (diff)
downloadlibxml2-2d84a89478ccf8e65d6ab94a919f403cc1968d47.tar.gz
Fixed a really nasty problem raised by a DocBook XSLT transform provided
* entities.c parser.c tree.c include/libxml/entities.h: Fixed a really nasty problem raised by a DocBook XSLT transform provided by Sebastian Bergmann Daniel
Diffstat (limited to 'entities.c')
-rw-r--r--entities.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/entities.c b/entities.c
index dbdf9ebf..8f3dfd8a 100644
--- a/entities.c
+++ b/entities.c
@@ -48,7 +48,7 @@ static xmlHashTablePtr xmlPredefinedEntities = NULL;
static void xmlFreeEntity(xmlEntityPtr entity) {
if (entity == NULL) return;
- if ((entity->children) &&
+ if ((entity->children) && (entity->owner == 1) &&
(entity == (xmlEntityPtr) entity->children->parent))
xmlFreeNodeList(entity->children);
if (entity->name != NULL)
@@ -127,6 +127,7 @@ xmlAddEntity(xmlDtdPtr dtd, const xmlChar *name, int type,
ret->URI = NULL; /* to be computed by the layer knowing
the defining entity */
ret->orig = NULL;
+ ret->owner = 0;
if (xmlHashAddEntry(table, name, ret)) {
/*
@@ -847,6 +848,20 @@ xmlCreateEntitiesTable(void) {
}
/**
+ * xmlFreeEntityWrapper:
+ * @entity: An entity
+ * @name: its name
+ *
+ * Deallocate the memory used by an entities in the hash table.
+ */
+static void
+xmlFreeEntityWrapper(xmlEntityPtr entity,
+ const xmlChar *name ATTRIBUTE_UNUSED) {
+ if (entity != NULL)
+ xmlFreeEntity(entity);
+}
+
+/**
* xmlFreeEntitiesTable:
* @table: An entity table
*
@@ -854,7 +869,7 @@ xmlCreateEntitiesTable(void) {
*/
void
xmlFreeEntitiesTable(xmlEntitiesTablePtr table) {
- xmlHashFree(table, (xmlHashDeallocator) xmlFreeEntity);
+ xmlHashFree(table, (xmlHashDeallocator) xmlFreeEntityWrapper);
}
/**