From fc76800928058016894c36a03e9d25e6d6fd94a0 Mon Sep 17 00:00:00 2001 From: James Clark Date: Mon, 4 May 1998 01:38:32 +0000 Subject: [PATCH] Fix bug with > INIT_ATTS_SIZE attributes --- expat/xmlparse/xmlparse.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/expat/xmlparse/xmlparse.c b/expat/xmlparse/xmlparse.c index efb3ab02..11ebf760 100755 --- a/expat/xmlparse/xmlparse.c +++ b/expat/xmlparse/xmlparse.c @@ -803,7 +803,7 @@ static enum XML_Error storeAtts(XML_Parser parser, const ENCODING *enc, { ELEMENT_TYPE *elementType = 0; int nDefaultAtts = 0; - const char **appAtts = (const char **)atts; + const char **appAtts; int i; int n; @@ -815,13 +815,15 @@ static enum XML_Error storeAtts(XML_Parser parser, const ENCODING *enc, n = XmlGetAttributes(enc, s, attsSize, atts); if (n + nDefaultAtts > attsSize) { - attsSize = 2*n; + int oldAttsSize = attsSize; + attsSize = n + nDefaultAtts + INIT_ATTS_SIZE; atts = realloc((void *)atts, attsSize * sizeof(ATTRIBUTE)); if (!atts) return XML_ERROR_NO_MEMORY; - if (n > attsSize) + if (n > oldAttsSize) XmlGetAttributes(enc, s, n, atts); } + appAtts = (const char **)atts; for (i = 0; i < n; i++) { ATTRIBUTE_ID *attId = getAttributeId(parser, enc, atts[i].name, atts[i].name -- 2.40.0