From f4f4e4853a925905deb77a72a3311ab683fbeeb5 Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Mon, 25 Aug 2008 08:57:48 +0000 Subject: [PATCH] rework the patch to avoid some ABI issue with people allocating entities * include/libxml/entities.h entities.c SAX2.c parser.c: rework the patch to avoid some ABI issue with people allocating entities structure directly Daniel svn path=/trunk/; revision=3773 --- ChangeLog | 6 ++++++ SAX2.c | 3 ++- entities.c | 10 +++++----- include/libxml/entities.h | 1 - parser.c | 17 +++++++++-------- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 781466a2..ab14345a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Aug 25 10:56:30 CEST 2008 Daniel Veillard + + * include/libxml/entities.h entities.c SAX2.c parser.c: rework + the patch to avoid some ABI issue with people allocating + entities structure directly + Wed Aug 20 19:02:01 CEST 2008 Daniel Veillard * include/libxml/parser.h include/libxml/entities.h entities.c diff --git a/SAX2.c b/SAX2.c index a8139602..80cd1bdb 100644 --- a/SAX2.c +++ b/SAX2.c @@ -580,7 +580,8 @@ xmlSAX2GetEntity(void *ctx, const xmlChar *name) return(NULL); } ret->owner = 1; - ret->checked = 1; + if (ret->checked == 0) + ret->checked = 1; } return(ret); } diff --git a/entities.c b/entities.c index 3e59ec12..91a39780 100644 --- a/entities.c +++ b/entities.c @@ -31,35 +31,35 @@ static xmlEntity xmlEntityLt = { NULL, NULL, NULL, NULL, NULL, NULL, BAD_CAST "<", BAD_CAST "<", 1, XML_INTERNAL_PREDEFINED_ENTITY, - NULL, NULL, NULL, NULL, 0, 1, 0 + NULL, NULL, NULL, NULL, 0, 1 }; static xmlEntity xmlEntityGt = { NULL, XML_ENTITY_DECL, BAD_CAST "gt", NULL, NULL, NULL, NULL, NULL, NULL, BAD_CAST ">", BAD_CAST ">", 1, XML_INTERNAL_PREDEFINED_ENTITY, - NULL, NULL, NULL, NULL, 0, 1, 0 + NULL, NULL, NULL, NULL, 0, 1 }; static xmlEntity xmlEntityAmp = { NULL, XML_ENTITY_DECL, BAD_CAST "amp", NULL, NULL, NULL, NULL, NULL, NULL, BAD_CAST "&", BAD_CAST "&", 1, XML_INTERNAL_PREDEFINED_ENTITY, - NULL, NULL, NULL, NULL, 0, 1, 0 + NULL, NULL, NULL, NULL, 0, 1 }; static xmlEntity xmlEntityQuot = { NULL, XML_ENTITY_DECL, BAD_CAST "quot", NULL, NULL, NULL, NULL, NULL, NULL, BAD_CAST "\"", BAD_CAST "\"", 1, XML_INTERNAL_PREDEFINED_ENTITY, - NULL, NULL, NULL, NULL, 0, 1, 0 + NULL, NULL, NULL, NULL, 0, 1 }; static xmlEntity xmlEntityApos = { NULL, XML_ENTITY_DECL, BAD_CAST "apos", NULL, NULL, NULL, NULL, NULL, NULL, BAD_CAST "'", BAD_CAST "'", 1, XML_INTERNAL_PREDEFINED_ENTITY, - NULL, NULL, NULL, NULL, 0, 1, 0 + NULL, NULL, NULL, NULL, 0, 1 }; /** diff --git a/include/libxml/entities.h b/include/libxml/entities.h index d464cecb..fdd72225 100644 --- a/include/libxml/entities.h +++ b/include/libxml/entities.h @@ -57,7 +57,6 @@ struct _xmlEntity { const xmlChar *URI; /* the full URI as computed */ int owner; /* does the entity own the childrens */ int checked; /* was the entity content checked */ - unsigned long nbentities; /* the number of entities references */ }; /* diff --git a/parser.c b/parser.c index 371e7ed0..a3915dc0 100644 --- a/parser.c +++ b/parser.c @@ -2421,7 +2421,7 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len, goto int_error; ctxt->nbentities++; if (ent != NULL) - ctxt->nbentities += ent->nbentities; + ctxt->nbentities += ent->checked; if ((ent != NULL) && (ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) { if (ent->content != NULL) { @@ -2471,7 +2471,7 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len, goto int_error; ctxt->nbentities++; if (ent != NULL) - ctxt->nbentities += ent->nbentities; + ctxt->nbentities += ent->checked; if (ent != NULL) { if (ent->content == NULL) { if (xmlLoadEntityContent(ctxt, ent) < 0) { @@ -3555,7 +3555,7 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) { ent = xmlParseEntityRef(ctxt); ctxt->nbentities++; if (ent != NULL) - ctxt->nbentities += ent->nbentities; + ctxt->nbentities += ent->checked; if ((ent != NULL) && (ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) { if (len > buf_size - 10) { @@ -5083,7 +5083,7 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) { } } if (cur != NULL) { - cur->nbentities = ctxt->nbentities - oldnbent; + cur->checked = ctxt->nbentities - oldnbent; if (cur->orig != NULL) xmlFree(orig); else @@ -6594,7 +6594,7 @@ xmlParseReference(xmlParserCtxtPtr ctxt) { xmlErrMsgStr(ctxt, XML_ERR_INTERNAL_ERROR, "invalid entity type found\n", NULL); } - ent->nbentities = ctxt->nbentities - oldnbent; + ent->checked = ctxt->nbentities - oldnbent; if (ret == XML_ERR_ENTITY_LOOP) { xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL); return; @@ -6651,9 +6651,10 @@ xmlParseReference(xmlParserCtxtPtr ctxt) { list = NULL; } } - ent->checked = 1; + if (ent->checked == 0) + ent->checked = 1; } - ctxt->nbentities += ent->nbentities; + ctxt->nbentities += ent->checked; if (ent->children == NULL) { /* @@ -6662,7 +6663,7 @@ xmlParseReference(xmlParserCtxtPtr ctxt) { * though parsing for first checking go though the entity * content to generate callbacks associated to the entity */ - if (was_checked == 1) { + if (was_checked != 0) { void *user_data; /* * This is a bit hackish but this seems the best